im exierience 一个奇怪的问题。
我试图使用 VBS 脚本调用 CMD,但它挂在最奇怪的点。
这是我的cmd的oExecShell.StdOut.ReadLine挂起:
set targetDir=\BackupstorageServername$2014-11-28_12-00
if not exist \BackupstorageServername$2014-11-28_12-00 (mkdir \BackupstorageServername$2014-11-28_12-00 )
Rem Works Fine
set LogDir=\BackupstorageServername$2014-11-28_12-00Logs
Rem Does not work for some strange Reason
echo "here"
"here"
然后它挂起,杀死它/应该遵循的行是:
echo %LogDir%
echo "we have the problem"
有人有吗?
以下是启动CMD的一些代码:
strAction = "C:makeBackup_test.cmd"
Dim WshShell : Set WshShell = CreateObject("WScript.Shell")
strAction = Wshshell.expandenvironmentstrings(strAction)
Dim oExecShell : Set oExecShell = WshShell.Exec(strAction)
Do While oExecShell.Status = 0
WScript.Sleep 100
Loop
writelog("... ExitCode is: " & oExecShell.ExitCode)
LastShellOutput = ""
Do While not(oExecShell.StdOut.AtEndOfStream)
LastShellOutput = LastShellOutput & oExecShell.StdOut.ReadLine & vbCrlf
Loop
writelog("StdOut: " & LastShellOutput)
有人有想法吗?
使用 CMD/C 调用 int 解决了这个问题。(strAction = "CMD/C C:\makeBackup_test.cmd")