用VBS调用CMD挂起echo

时间:2014-11-28 12:26:17

标签: vbscript cmd

im exierience一个奇怪的问题。

我试图用vbs脚本调用cmd并且它在最奇怪的点上挂起。

继承我挂起的cmd的oExecShell.StdOut.ReadLine:

set targetDir=\\Backupstorage\Servername$\2014-11-28_12-00
if not exist \\Backupstorage\Servername$\2014-11-28_12-00 (mkdir \\Backupstorage\Servername$\2014-11-28_12-00 ) 
Rem Works Fine
 set LogDir=\\\Backupstorage\Servername$\2014-11-28_12-00\Logs 
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) 

有人有想法吗?

1 个答案:

答案 0 :(得分:0)

用CMD / C调用int解决了它。 (strAction =“CMD / C C:\ makeBackup_test.cmd”)