0
當我執行從Windows批處理文件下面的命令翻譯批處理命令一個VBScript Shell命令
"e:\cdsdk\direct.exe" -f"e:\cdsdk\MyCred.txt" < "\\MyServer\ConfigFiles\MyParams.CDConfig" > "\\MyServer\MyLog.log"
它成功地執行與在MyCred.txt文件中指定的憑據direct.exe程序使用MyParams.CDConfig中指定的參數。它將輸出記錄到文件MyLog.log。
然而,當我運行VB腳本下面,我得到的消息時發生
以下錯誤:
While processing the command line, 'M' was encountered, but a '/' or a '-' was expected.
我有什麼做的就是同樣的命令在VBScript中的工作?
SET oFS = CreateObject("Scripting.FileSystemObject")
SET sout = oFS.GetStandardStream(1)
sout.WriteLine("Message to Console: Start")
Dim CDCmd
Dim Quote
Quote = CHR(34)
CredFile = "e:\cdsdk\MyCred.txt"
ConfigFile = "\\MyServer\ConfigFiles\MyParams.CDConfig"
CdLogFile = "\\MyServer\MyLog.log"
CDCmd = Quote & "e:\cdsdk\direct.exe" & Quote & " -f" & Quote & CredFile & Quote & " < " & Quote & ConfigFile & Quote & " > " & Quote & CdLogFile & Quote
sout.WriteLine("Message to Console: CDCmd=" & CDCmd)
Set objShell = WScript.CreateObject("WScript.Shell")
Dim ReturnValue
ReturnValue = -1
ReturnValue = objShell.Run (CDCmd, 3, true)
sout.WriteLine("Return Value=" & ReturnValue)
sout.WriteLine("Message to Console: End")
WScript.Quit ReturnValue
當我比較CDCmd的寫入控制檯的值,它看起來一樣的批處理命令時,在批處理文件執行的工作。
對不起。什麼是comspec?它看起來可能是任何用戶定義的變量。你能否詳細說明一下,或者舉個例子? – ChadD