我正在尝试将工作目录作为命名参数传递给vbscript。系统通常会扩展“。”到当前路径,但是当我检查命名参数时,我只得到字符串“。”
这是命令行:
cscript myscript.vbs /a:"first arg" /b:second /c:.
这是脚本:
dim args : set args = wscript.arguments.named
wscript.echo args.item("a")
wscript.echo args.item("b")
wscript.echo args.item("c")
这是输出:
first arg
second
.
答案 0 :(得分:1)
Set fso = CreateObject("Scripting.FileSystemObject")
WScript.Echo fso.GetAbsolutePathName(args("c"))
或者您可以使用/c:"%CD%"
代替/c:.
。
如果您总是想知道当前目录,则不需要将其作为参数传递。只需使用
cwd = CreateObject("WScript.Shell").CurrentDirectory