Using PSEXEC returns no output from the remote task
Asked Answered
P

2

7

I am using psexec to run an exe on a server. The command runs ok, but there is no output on my local console.

This is the command I am using:

psexec.exe \\my-machine ping localhost

which results in:

PsExec v1.94 - Execute processes remotely
Copyright (C) 2001-2008 Mark Russinovich
Sysinternals - www.sysinternals.com

ping exited with error code 0.

if I try to run this localy however, it works fine

psexec.exe \\localhost ping localhost

PsExec v1.94 - Execute processes remotely
Copyright (C) 2001-2008 Mark Russinovich
Sysinternals - www.sysinternals.com



Pinging my-machine.mydomain.com [1.1.1.1] with 32 bytes of data:

Reply from 1.1.1.1: bytes=32 time=2ms TTL=128
Reply from 1.1.1.1: bytes=32 time<1ms TTL=128
Reply from 1.1.1.1: bytes=32 time<1ms TTL=128
Reply from 1.1.1.1: bytes=32 time<1ms TTL=128

Ping statistics for 1.1.1.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 2ms, Average = 0ms
ping exited on localhost with error code 0.
Poeticize answered 3/8, 2009 at 11:0 Comment(0)
P
4

It turns out that (at least in this case) you need to use the fully qualified machine name when kicking off psexec. I haven't figured out why this is but it does the trick.

psexec.exe \\my-machine.mydomain.com ping localhost

and now all the output of the command is returned.

Poeticize answered 3/8, 2009 at 11:2 Comment(2)
it doesnt work for me. I tried both with fqn and without. Is there any other tool different than psexec.exeTabina
5 years on I guess things change, although you would think MS would maintain backward compatibility :-)Poeticize
O
0

I already gave three variations for your problem kindly check this URL.

This will copy the iname.bat file in remote system and execute it and save the result in success.txt inside local machine directory in which we are running PSexec

PsExec.exe \remote_ip -u Administrator -p test@123 -c -f "iname.bat">success.txt

this will run test.bat present on remote machine and make Success.txt on remote machine

PsExec.exe \remote_ip -u Administrator -p test@123 -i cmd /C "C:\abhi\test.bat > C:\abhi\success.txt"

this will run test.bat present on remote machine and make Success.txt on localmachine

PsExec.exe \remote_ip -u Administrator -p test@123 cmd /C "C:\abhi\test.bat">success.txt

if you want to see output then remove redirection

PsExec.exe \remote_ip -u Administrator -p test@123 -c -f "iname.bat"

PsExec.exe \remote_ip -u Administrator -p test@123 -i cmd /C "C:\abhi\test.bat

Orva answered 3/7, 2018 at 6:28 Comment(1)
Yeah I think 9yrs ago when I asked this question we were doing something similar. it just sucks that you have to work around it like that. Although I found in my case that using the fqdn did the trick.Poeticize

© 2022 - 2025 — McMap. All rights reserved.