batch-file - 在 VBScript 中替换 %~dp0

标签 batch-file vbscript

我在 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
    

    关于batch-file - 在 VBScript 中替换 %~dp0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14677199/

    相关文章:

    c# - 使用 C# 中的参数运行批处理文件

    batch-file - 非阻塞批处理文件执行

    javascript - 使用客户端脚本语言包含外部 html 文件

    excel - Selection.End(xlToRight) 不起作用

    json - ASP JSON : Object not a collection

    encoding - 使用 Stream_StringToBinary 进行 Base64 编码会插入换行符,从而破坏字符串?

    batch-file - 如何批量处理空白变量?

    batch-file - 在命令提示符中使用变量

    java - 如何使用 J Connector 和其他 jar 文件为 Java 程序创建 bat 文件?

    VBScript 返回 Windows 产品 key