PsExec / StdErr
Joined: 16 November 2012
Posted: 16 November 2012 at 4:17pm
Has anyone found a way to redirect the StdErr output of PSExec (or any other pstool)? I'm just attempting to inspect the "error code" output of a command in which I'm executing regedit on a remote server:
psexec \\$servername /s /accepteula regedit.exe /s c:\temp\addstuff.reg
+ CategoryInfo : NotSpecified: (:String) , RemoteException
+ FullyQualifiedErrorId : NativeCommandError
PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com
Connecting to ncs-arm01-v-a...Starting PsExec service on servername..Connecting with PsExec service on servername...Starting c:\windows\regedit.exe on
c:\windows\regedit.exe exited on servername with error code 0.
(I want to ensure that the above command exits with code 0 while my script is processing)
Using the stderr -> stdout redirect does not seem to be working (2>&1)
Joined: 18 September 2012
Location: Sutton, MA
Instead of redirecting stderr to stdout 2>&1, can you simply try redirecting stderr to a file:
psexec \\$servername /s /accepteula regedit.exe /s c:\temp\addstuff.reg 1>"stdout.txt" 2>"stdERR.txt"
Note that 1> and 2> point to Different files, otherwise 2> will try to open the 1> file and it is already in use.
You may need to be more specific Where these files are written. (I assume \\$servername\current path\stderr.txt may need to be better defined than I have listed above.)
How does this work for you?
|Forum Jump||Forum Permissions
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum