Filename string space issue in VBScript

前端 未结 1 1716
北海茫月
北海茫月 2021-01-24 14:29

I get an error when I run this command and I am unsure why.

Running VBScript to execute a bat file, I want to output any error messages to a log file. So to do this I ha

相关标签:
1条回答
  • 2021-01-24 15:12

    I think the issue here is because the cmd /k needs the commands passed to it to be encapsulated in double quotes.

    So the command (removed THISSTRING as you said that was just to trigger the error)

    WshShell.Run "cmd /k ""C:\Program Files (x86)\Folder\File.bat"" > ""C:\Program Files(x86)\Folder\File.txt""", 1, True
    

    Becomes

    WshShell.Run "cmd /k """"C:\Program Files (x86)\Folder\File.bat"" > ""C:\Program Files(x86)\Folder\File.txt""""", 1, True
    

    and run's as

    cmd /k ""C:\Program Files (x86)\Folder\File.bat" > "C:\Program Files(x86)\Folder\File.txt""
    
    0 讨论(0)
提交回复
热议问题