Page 1 of 1

Multiple Command at Once

Posted: 13 Sep 2012 00:26
by Dipesh
Hello to all

I looking for command that run few command at one time. i am update lab with psexec.exe

like "psexec \\pc1 -username -password -c java.exe /qn"

i want run this command at same time in 10 pc's.

like - "psexec \\pc1 -username -password -c java.exe /qn"
"psexec \\pc2 -username -password -c java.exe /qn"
"psexec \\pc3 -username -password -c java.exe /qn" at same time..


it is possible with batch file ??

Thanks,

Re: Multiple Command at Once

Posted: 13 Sep 2012 02:50
by abc0502
EDIT: Changed the Code so it start working in all PCs

If the user and pass the same in all PCs
Make a list of all the PCs you are going to run this command on it, the list should be like this:

Code: Select all

PC1
PC2
PC3

PC1 is the PC name or IP depending on your command input,
and run this command from a batch file that exist in the same folder with the above txt list

Code: Select all

@Echo off & cls
For /F "tokens=*" %%A in ('type "PC_list.txt"') Do (
          start "%%A" psexec \\%%A -username -password -c java.exe /qn"
)
pause

the PC_list.txt is the PC list file name, and the username & password is the admin username and password

IF each PC require differant Username and Password
The list should look like this:

Code: Select all

PC1:Username:Password
PC2:Username:Password
PC3:Username:Password
PC4:Username:Password

the " : " is a separator if this sign exist in your password or PC name or username just change it with any charachter
and the Batch should be like this:

Code: Select all

@echo off & cls
For /F "tokens=1,2,3 delims=:" %%A in ('type "PC_list.txt"') Do (
          start "%%A" psexec \\%%A -%%B -%%C -c java.exe /qn"
)
pause

The %%A = PC name or IP
The %%B will be the Username "2nd token"
The %%C will be the Password "3rd token"
The "delims=:" is the separator, if you changed the separator in the txt file change it here.

Re: Multiple Command at Once

Posted: 13 Sep 2012 03:51
by Dipesh
First thanks for the replay but what happens when i start it do one by one like pc1 then pc2 then pc3. java is very long process to install it possible that it start in few PC's at time ????

start executing in every PC as same time not after it after. when process start in first PC then it also start in last PC also...

Thanks

Re: Multiple Command at Once

Posted: 13 Sep 2012 03:59
by abc0502
I changed the code above, all setup will start in all pcs at once and each window will have the pc name as a title

Re: Multiple Command at Once

Posted: 13 Sep 2012 05:15
by Dipesh
thanking you "abc0502" they open new window if it is possible to do this things in same window or one window ??? this work fine but i have 20 pc per lab so my desktop if full of windows :).

if possible then please tell me.

Re: Multiple Command at Once

Posted: 13 Sep 2012 05:41
by abc0502
if they all in one window it must be one by one but starting each pc in separate window enable you to run all in the same time, but we can change the code so it start all minimized

to start all minimized, after the start command add "/min" like this:
start "%%A" /min psexec \\%%A -username -password -c java.exe /qn"

Re: Multiple Command at Once

Posted: 13 Sep 2012 05:44
by Dipesh
Thanking you very much bro....