user2307236
user2307236

Reputation: 745

Run a batch file on remote host using PsExec

I am experimenting with PsExec and I am trying to run a batch file on a remote host from a local PC on the same LAN. The batch file has been tested on the local PC and works fine. I managed to connect to the remote host via PsExec using the below commands.

PsExec -u Username -p Password \\Remote_Host_IP C:\Path_to_batch_file\Batch.bat

I am getting this error:

PsExec could not start C:\Path_to_batch_file\Batch.bat on Remote_Host_IP: The system cannot find the file specified.

This is probably occurring since it is searching for the file on the remote host while the file is located on the local PC thus not finding the file.

I do not want to make any manual intervention on the remote host.

After trying hard to find the correct commands on the net I cannot solve this issue.

Upvotes: 0

Views: 18400

Answers (4)

Usagi
Usagi

Reputation: 1

In my job (domain users) I run a BAT script simply as just psexec -s -h \\ip -u "localhost\administrador" -p "password" \\ip\file.bat

Here in my house with a Pro and an educational version, this one is VMware, I cannot run a BAT script if I didn't use -c, if I try to run without -c I get:

psexec could not star "\file.bat" on "remote ip"

The batch script is perfectly accessible from the remote machine with no problems.
I cannot understand that.

Upvotes: 0

Harshita
Harshita

Reputation: 1

Run it as:

PsExec \Remote_Host_IP -u Username -p Password cmd/c "C:\Path_to_batch_file\Batch.bat"

This should fix it

Upvotes: -1

Nando_Naldo
Nando_Naldo

Reputation: 11

If you want you can try this:

PsExec.exe @pc_list.txt >>pc_log.txt -c D:\PC\pc.bat

Where:

pc_list.txt is a list of all your PC in your network
       pc_log.txt is a log
       D:\PC\pc.bat is the path where your script is

You can schedule it from a server that has access on all your network with task scheduler

Upvotes: 1

manoch
manoch

Reputation: 1

Try this.

Psexec \\remotehost -u username -p password -c local_path\file.bat

Upvotes: 0

Related Questions