How to Run multiple command remotely using PSEXEC?

31,805

Solution 1

If you have access to the remote machine (which I assume you do since you can run PSEXEC) you can copy a batch file to the remote system first, then use psexec to run the batch file.

Solution 2

The command following the first one is a new command; the first command was psexec followed by something, not something on its own.

Make it one compound command:

psexec -i \192.158.30.135 -u username -p password (cmd1 & cmd2)

Read http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds_o.mspx?mfr=true for more info.

Solution 3

I believe you will find the second command is running on the local machine, not the remote one. You need to use quote marks like this:

psexec \\servername cmd /c "dir"

I used it and this is working fine.

Share:
31,805

Related videos on Youtube

Giriraj
Author by

Giriraj

Updated on September 18, 2022

Comments

  • Giriraj
    Giriraj almost 2 years

    I am try to use multiple command with psexec tools but i am only remotely entered in that computer but it won't be perform another command

    psexec -i \\192.168.30.135 -u username -p password cmd & del abc.exe
    

    by using this command line parameter i am able to only entered in that machine remotely but it can't perform an del command to delete that file can any one having solution about this please give me.

  • Giriraj
    Giriraj over 12 years
    Thanks for your replay but can this command working on Windows 7. I had tried this command which you had given but its giving me an error the system cant be find the file specified. psexec -s \\192.158.30.135 -u user -p pass (cmd & del cleaner.exe)
  • Giriraj
    Giriraj over 12 years
    thanks for your replay. but after send this batch file it will take memory storage but i want to do that no memory storage is occupying by any file. Actually i am try to design one software that is remotely silently install software on remote computer.
  • adaptr
    adaptr over 12 years
    What is "cmd"? If you're just starting the command interpreter - that's not a command, that's what psexec DOES.
  • Giriraj
    Giriraj over 12 years
    psexec is one type of command which is running by pstool in which we are accessing remote machines.and cmd is command interpreter so first i am run cmd and than passing del command to delete cleaner.exe files to delete from remote computer.
  • Giriraj
    Giriraj over 12 years
    how to run bat file remotely using cmd can you please giving me command line parameter as example so i can do that.
  • adaptr
    adaptr over 12 years
    The delete command is the argument to the cmd command; it is still just one command: cmd del cleaner.exe
  • Giriraj
    Giriraj over 12 years
    can we are able to run multiple command on cmd in a single argument? if it is possible than can u please giving me the example of that thing? can that multiple command run remotely run on another machine?