Sysinternals Homepage
Forum Home Forum Home > Sysinternals Utilities > PsTools
  New Posts New Posts RSS Feed - PSEXEC running batch file on remote PC
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

PSEXEC running batch file on remote PC

 Post Reply Post Reply
Author
Message
tonydotigr View Drop Down
Newbie
Newbie


Joined: 13 November 2009
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote tonydotigr Quote  Post ReplyReply Direct Link To This Post Topic: PSEXEC running batch file on remote PC
    Posted: 13 November 2009 at 7:48pm
Hi all-
 
I'm trying to use PSEXEC to run a batch file on a remote PC.  The command I'm using is psexec \\computer.domain.com - u username -i -d cmd /c \\computer\folder\program_copy.bat

I get cmd exited on computer with error code 0.  I checked the PC and the batch file doesn't seem to run.  Is there a way to see what is happening?  Or am I missing something?
 
Thanks.
Back to Top
SvenBomwollen View Drop Down
Senior Member
Senior Member


Joined: 29 August 2008
Location: Germany
Status: Offline
Points: 1630
Post Options Post Options   Thanks (0) Thanks(0)   Quote SvenBomwollen Quote  Post ReplyReply Direct Link To This Post Posted: 14 November 2009 at 11:57am
Hello, tonydotigr.

Originally posted by tonydotigr tonydotigr wrote:

psexec \\computer.domain.com -u username -i -d cmd /c \\computer\folder\program_copy.bat
Assuming that  computer.domain.com and computer are the same computer, you should try to run the command like this instead
Quote psexec \\computer.domain.com -u username -i -d cmd /c drive:\folder\program_copy.bat
where drive: is the drive letter as it will be seen when you are logged on to computer, i.e. C: or D: or E: or ...

About logging what happens:

In case you can run your psexec commandline without the -d (detach) option, you might redirect the screen output of your psexec command line to a file.

Quote psexec \\computer.domain.com -u username -i cmd /c drive:\folder\program_copy.bat > "%temp%\psexeclog.txt" 2>&1
The file "%temp%\psexeclog.txt" on your local machine will hold all screen output (stdout and stderr) which is generated by your psexec commandline.

In case you have to run your psexec commandline with the -d (detach) option, you should modify the command lines inside the script
program_copy.bat in such a way that they write their screen output to a file. The file will be stored on the remote machine computer.domain.com in this case.

Kind regards,
SvenBomwollen





Edited by SvenBomwollen - 14 November 2009 at 11:57am
Back to Top
mvaviya View Drop Down
Newbie
Newbie
Avatar

Joined: 05 October 2012
Location: India
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote mvaviya Quote  Post ReplyReply Direct Link To This Post Posted: 05 October 2012 at 8:51am
Can anyone guide me how can i write below syntax for *.bat file that accepts command line parameter (x_y_z) as input.
e.g. :
Minesh Vaviya | Software Engineer
Back to Top
upwithdawn View Drop Down
Newbie
Newbie


Joined: 05 October 2012
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote upwithdawn Quote  Post ReplyReply Direct Link To This Post Posted: 05 October 2012 at 1:51pm
I can help with batch files but I'm afraid I don't understand the question ...
Back to Top
mvaviya View Drop Down
Newbie
Newbie
Avatar

Joined: 05 October 2012
Location: India
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote mvaviya Quote  Post ReplyReply Direct Link To This Post Posted: 05 October 2012 at 1:58pm
Hi,
 
My Question here is i want to access a *.BAT file on remote server.
Need to be executed only on server.
This *.BAT file accepts a command line parameter(it is a BAT file that takes input).
So i require a syntax how i can execute that *.BAT on Server?
 
Thanks


Edited by mvaviya - 05 October 2012 at 1:59pm
Minesh Vaviya | Software Engineer
Back to Top
Caleb11 View Drop Down
Newbie
Newbie


Joined: 07 October 2012
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote Caleb11 Quote  Post ReplyReply Direct Link To This Post Posted: 07 October 2012 at 10:31pm
psexec \\computer.domain.com -u username -p password cmd /k  "drive:\folder\program_copy.bat < input"

Im not sure if that would work, input redirection is something i have not tried, but i have read that it is not possible through PSEXEC ... is this right anyone?

I read that it works but it bugged and can cause hung sessions ect... this may have been resolved in a later release ... i dont know.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down