Solved

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

Posted on 2008-10-16
4
1,739 Views
Last Modified: 2012-05-05
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
Comment
Question by:einarbrown
  • 2
  • 2
4 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 22730046
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
 
LVL 6

Author Closing Comment

by:einarbrown
ID: 31506676
Thanks allot! It workt!
0
 
LVL 6

Author Comment

by:einarbrown
ID: 22730454
It worked perfectly to pass it through cmd!

Thanks!
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 22730921
Happy to help - thanx for the grade! :^)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now