set ws = createobject("wscript.shell")
ws.currentdirectory = "D:\test\MyProject"
msgbox ws.currentdirectory
CurrentPath = createobject("Scripting.FileSystemObject").GetFolder(".").Path
msgbox CurrentPath
cd命令是更改当前工作目录,也就是命令对当前那个目录有效。在vbs中更改当前工作目录可以使用currentdirectory,他既可以设置当前目录,也可以返回当前目录情况。
test = createobject("Scripting.FileSystemObject").GetFolder(".").Path
当前目录的路径,修改一下
test =createobject("Scripting.FileSystemObject").GetFile(Wscript.ScriptFullName).ParentFolder.Path
CurrentPath = createobject("Scripting.FileSystemObject").GetFolder(".").Path
CurrentPath="D:\test\MyProject"
print CurrentPath