When I execute the following command from a Windows Batch file...
"e:\cdsdk\direct.exe" -f"e:\cdsdk\MyCred.txt" < "\\MyServer\ConfigFiles\MyParams.CDConfig" > "\\MyServer\MyLog.log"
It successfully executes the direct.exe program with the credentials specified in the MyCred.txt file using the parameters specified in the MyParams.CDConfig. It logs the output to the file MyLog.log.
However, when I run the VB Script below, I get the message
The Following error occurred:
While processing the command line, 'M' was encountered, but a '/' or a '-' was expected.
What do I have to do to get the same command working in 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
When I compare the value of CDCmd written to the Console, it looks the same as the batch command that works when executed in a batch file.