Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1764
  • Last Modified:

Difference between vb-scripts WScript.Shell and cmd.exe

I have a command that works perfectly in command-prompt (cmd.exe), but when I run it in a vb-script it does not work. What is the difference between WScript.Shell and cmd.exe? The command Im running is:

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "runas /user:"& user & " " & chr(34) & share & "\DOM_Mallar\Script\Robocopy.exe " & share & "\DOM_Mallar " & ProgramFiles & "\DOM_Mallar  /MIR /E /W:0 /R:2 /XD *Script*  > " & ProgramFiles & "\DOM_Mallar\cp_mallar.txt" & chr(34) & " | " & share & "\DOM_Mallar\script\sanur " & pwd
Set WshShell = WScript.CreateObject("WScript.Shell") 
WshShell.Run "runas /user:"& user & " " & chr(34) & share & "\DOM_Mallar\Script\Robocopy.exe " & share & "\DOM_Mallar " & ProgramFiles & "\DOM_Mallar  /MIR /E /W:0 /R:2 /XD *Script*  > " & ProgramFiles & "\DOM_Mallar\cp_mallar.txt" & chr(34) & " | " & share & "\DOM_Mallar\script\sanur " & pwd

Open in new window

0
einarbrown
Asked:
einarbrown
  • 2
  • 2
1 Solution
 
sirbountyCommented:
Try passing it through cmd...

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd /c runas /user:"& user & " " & chr(34) & share & "\DOM_Mallar\Script\Robocopy.exe " & share & "\DOM_Mallar " & ProgramFiles & "\DOM_Mallar  /MIR /E /W:0 /R:2 /XD *Script*  > " & ProgramFiles & "\DOM_Mallar\cp_mallar.txt" & chr(34) & " | " & share & "\DOM_Mallar\script\sanur " & pwd
0
 
einarbrownAuthor Commented:
Thanks allot! It workt!
0
 
einarbrownAuthor Commented:
It worked perfectly to pass it through cmd!

Thanks!
0
 
sirbountyCommented:
Happy to help - thanx for the grade! :^)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now