Solved

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

Posted on 2008-10-16
4
1,749 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 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