Solved

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

Posted on 2008-10-16
4
1,741 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

896 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

15 Experts available now in Live!

Get 1:1 Help Now