Multiple Command at Once

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Dipesh
Posts: 23
Joined: 13 Sep 2012 00:05

Multiple Command at Once

#1 Post by Dipesh » 13 Sep 2012 00:26

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,

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Multiple Command at Once

#2 Post by abc0502 » 13 Sep 2012 02:50

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.
Last edited by abc0502 on 13 Sep 2012 03:58, edited 1 time in total.

Dipesh
Posts: 23
Joined: 13 Sep 2012 00:05

Re: Multiple Command at Once

#3 Post by Dipesh » 13 Sep 2012 03:51

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

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Multiple Command at Once

#4 Post by abc0502 » 13 Sep 2012 03:59

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

Dipesh
Posts: 23
Joined: 13 Sep 2012 00:05

Re: Multiple Command at Once

#5 Post by Dipesh » 13 Sep 2012 05:15

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.

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Multiple Command at Once

#6 Post by abc0502 » 13 Sep 2012 05:41

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"

Dipesh
Posts: 23
Joined: 13 Sep 2012 00:05

Re: Multiple Command at Once

#7 Post by Dipesh » 13 Sep 2012 05:44

Thanking you very much bro....

Post Reply