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?

[Webinar] Streamline your web hosting managementRegister Today

x
 
cookreConnect With a Mentor Commented:
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
 
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:
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
All Courses

From novice to tech pro — start learning today.