当我从 Windows 批处理文件执行以下命令时...
"e:\cdsdk\direct.exe" -f"e:\cdsdk\MyCred.txt" < "\\MyServer\ConfigFiles\MyParams.CDConfig" > "\\MyServer\MyLog.log"
它使用 MyParams.CDConfig 中指定的参数,使用 MyCred.txt 文件中指定的凭据成功执行 direct.exe 程序。它将输出记录到文件 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 的值时,它看起来与在批处理文件中执行的批处理命令相同。