我正在尝试运行以下命令并使用VBscript返回它的输出:
dir /A-d "C:\Windows\Minidump" | find /c "/"
我有以下脚本,但它不起作用(可能是因为" charachters:
Wscript.Echo runCMD("dir /A-d "C:\Windows\Minidump" | find /c "/"")
Function runCMD(strRunCmd)
Set objShell = WScript.CreateObject("WScript.Shell")
Set objExec = objShell.Exec(strRunCmd)
strOut = ""
Do While Not objExec.StdOut.AtEndOfStream
strOut = strOut & objExec.StdOut.ReadLine()
Loop
Set objShell = Nothing
Set objExec = Nothing
runCMD = strOut
End Function
有关如何实现这一目标的任何建议吗?
答案 0 :(得分:3)
dir
是固有的;你需要%comspec%
。双引号需要在VBScript中用双引号转义:
Wscript.Echo runCMD("%comspec% /c dir /A-d ""C:\Windows\Minidump"" | find /c ""/""")