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
Author
Message
cncoats View Drop Down
Newbie
Newbie


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:

<command>
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 - 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
servername...
c:\windows\regedit.exe exited on servername with error code 0.
</command>


(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
Avatar

Joined: 18 September 2012
Location: Sutton, MA
Status: Offline
Points: 112
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.03
Copyright ©2001-2015 Web Wiz Ltd.