Solved PSEXEC to run .exe on remote client and log results

September 19, 2012 at 09:06:28
Specs: Windows XP
I am using psexec to run an .exe that is stored in a directory called "temp" on a remote computer. After the .exe is finished executing a results log file is created in another direcotry called "logs". What I want happen is to have a new log file generated each time a run the script. I would like the log file to contain the current date, computer name and time that the script was ran.

I am running something like this currently:

psexec \\client-01 c:/temp/execute.exe /q
echo %date%, %computername%, %time% >> Logs/results.log 2>&1

When I run this script I get the following output:

date, computername, time......that is it...........

Shouldn't I get a message that says the the .exe exited on the client with error code whatever?


See More: PSEXEC to run .exe on remote client and log results

Report •


#1
September 19, 2012 at 12:03:27
✔ Best Answer
psexec \\client-01 c:/temp/execute.exe /q >> Logs/results.log 2>&1
echo %date%, %computername%, %time% >> Logs/results.log

maybe this instead?

:: mike


Report •

#2
September 19, 2012 at 18:03:11
dumb question dept, but won't the remote executable create the logfile on the remote machine? (or, is the logfile created by psexec, in which case it would assumadly be local). You may need come "copy" operations to obtain the logfile.
It is confusing, because you use different slashes from what I am used to. Not sure what is running where (also, i am unfamiliar with psexec, although i've heard of it. Member of the "putty" suite?) meanwhile I'll google it.

Report •

#3
September 19, 2012 at 20:02:28
PsExec is part of Sysinternals, a "company" purchased by Microsoft.

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
September 20, 2012 at 09:28:59
@mikelinus

Thanks. This edit helped me with the error code issue but I still need help with the script actually creating a new log file every time I run it instead of adding to the existing log file.

@nbrane

The way this script works is psexec executes the .exe on the remote client (\\client-01) but creates a log on the local machine


Report •

#5
September 20, 2012 at 09:32:59
Use ">>" instead of ">".

How To Ask Questions The Smart Way


Report •

#6
September 20, 2012 at 10:18:58
Reading at the posting #1 with #4, are you trying to create a new log each time, or a new log entry?

IF the second, Razor2.3, makes excellent sense as always. otherwise you could consider

psexec \\client-01 c:/temp/execute.exe /q >>Logs/%date%%computername%%time%.log 2>&1
and skip the
echo %date%, %computername%, %time% >> Logs/results.log

:: mike


Report •

Ask Question