6

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.

Bart De Vos
  • 17,761
  • 6
  • 62
  • 81
Giriraj
  • 61
  • 1
  • 1
  • 3

3 Answers3

5

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.

Bart Silverstrim
  • 31,092
  • 9
  • 65
  • 87
  • 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. – Giriraj Jan 12 '12 at 06:03
  • how to run bat file remotely using cmd can you please giving me command line parameter as example so i can do that. – Giriraj Jan 12 '12 at 11:57
3

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.

adaptr
  • 16,479
  • 21
  • 33
  • 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 Jan 12 '12 at 05:56
  • What is "cmd"? If you're just starting the command interpreter - that's not a command, that's what psexec DOES. – adaptr Jan 12 '12 at 09:32
  • 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 Jan 12 '12 at 11:55
  • The delete command is the argument to the cmd command; it is still just one command: cmd del cleaner.exe – adaptr Jan 12 '12 at 16:44
  • 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? – Giriraj Jan 16 '12 at 05:58
2

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.

Lucas Kauffman
  • 16,818
  • 9
  • 57
  • 92