Execution Question

Hello

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?
LVL 1
gexenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hammadian2Commented:
i think u'll have to escape the \

ie. write \\ instead of \ in the whole string
0
gexenAuthor Commented:
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.
0
cookreCommented:
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"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cookreCommented:
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")
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.