batch-file – 替换VBScript中的%~dp0

我在VBScript中找不到任何替换%~dp0的内容

On error resume next
Set shell= createobject("WSCRIPT.SHELL")
Shell.run "%~dp0test.bat", vbhide

最佳答案

Set fso = CreateObject("Scripting.FileSystemObject")
GetTheParent = fso.GetParentFolderName(Wscript.ScriptFullName)

取自这里:

> how to get working drive and directory?

要在脚本中使用获取的值,请添加对需要其值的变量的引用.例如:

Shell.run GetTheParent & "\test.bat", vbhide
点赞