Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Execution Question

Posted on 2004-10-27
Medium Priority
Last Modified: 2010-04-17

I have this line in my code:

objShell.Run("psexec \\hostx.domain.com -s -u hostx -p hostxpass diruse /s /m /* " & "d:\root\" & " > " & "d:\root\will\test.txt")
If I echo the command out, and just copy and paste it into a command prompt, the script executes as expected.

However, if I run it using the above code, the command executes fine BUT it does not pipe it out into a file.  To double check, I made sure the program ran a longtime, and in the title bar it said \\hostx.domain.com -s -u hostx -p hostxpass diruse /s /m /* d:\root\ > d:\root\will\test.txt

Does anybody have any idea why the pipe out is working if I execute it from the command prompt, but not from the Run method?
Question by:gexen
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

Expert Comment

ID: 12428311
i think u'll have to escape the \

ie. write \\ instead of \ in the whole string

Author Comment

ID: 12428411
I don't believe that is the case in VBScript, as \ is not an escape operator as far as I know..

Also, the script executes correctly, the pipe doesn't work.  If it were an escape issue with the \'s, it wouldn't  have run correctly because it needs the full path "d:\root\" to execute.
LVL 22

Accepted Solution

cookre earned 2000 total points
ID: 12430178
When you run the cxommand that way, there's no command shell to see the redirect.  Instead, explicitly run the command shell with "cmd /c prog.exe args >filename"
LVL 22

Expert Comment

ID: 12430181
To wit:

objShell.Run("cmd /c psexec \\hostx.domain.com -s -u hostx -p hostxpass diruse /s /m /* " & "d:\root\" & " > " & "d:\root\will\test.txt")

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Make the most of your online learning experience.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

604 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