Run Command Line & Command From VBS

前端 未结 2 1402
北荒
北荒 2020-11-30 06:57

I need to run a command to copy a file from one location to another through Command Prompt using a vbs file. this is what I have however it keeps throwing an error at me.

相关标签:
2条回答
  • 2020-11-30 07:19

    The problem is on this line:

    oShell.run "cmd.exe /C copy "S:Claims\Sound.wav" "C:\WINDOWS\Media\Sound.wav"
    

    Your first quote next to "S:Claims" ends the string; you need to escape the quotes around your files with a second quote, like this:

    oShell.run "cmd.exe /C copy ""S:\Claims\Sound.wav"" ""C:\WINDOWS\Media\Sound.wav"" "
    

    You also have a typo in S:Claims\Sound.wav, should be S:\Claims\Sound.wav.

    I also assume the apostrophe before Dim oShell and after Set oShell = Nothing are typos as well.

    0 讨论(0)
  • 2020-11-30 07:20
    Set oShell = CreateObject ("WScript.Shell") 
    oShell.run "cmd.exe /C copy ""S:Claims\Sound.wav"" ""C:\WINDOWS\Media\Sound.wav"" "
    
    0 讨论(0)
提交回复
热议问题