Sysinternals Homepage
Forum Home Forum Home > Sysinternals Utilities > PsTools
  New Posts New Posts RSS Feed - PsExec / StdErr
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

PsExec / StdErr

 Post Reply Post Reply
cncoats View Drop Down

Joined: 16 November 2012
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote cncoats Quote  Post ReplyReply Direct Link To This Post Topic: PsExec / StdErr
    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

psexec.exe :
    + CategoryInfo          : NotSpecified: (:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals -
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)

Back to Top
rmetzger View Drop Down
Senior Member
Senior Member

Joined: 18 September 2012
Location: Sutton, MA
Status: Offline
Points: 128
Post Options Post Options   Thanks (0) Thanks(0)   Quote rmetzger Quote  Post ReplyReply Direct Link To This Post Posted: 21 November 2012 at 8:30pm
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?
Ron Metzger
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.06
Copyright ©2001-2016 Web Wiz Ltd.