Link to home
Start Free TrialLog in
Avatar of samih_habib
samih_habibFlag for Canada

asked on

Connecting to 5 different remote windows 2004 servers

I need a batch file ( windows batch file) to do the following:

1-      Connecting to 5 different remote windows 2004 servers  
2-      The user name : user01 password : password for each server to connect
3-      Action is to stop the iis and TmProxy service in all servers
4-      And write the result in text
Avatar of achaldave
achaldave
Flag of United States of America image

here is the simple batch file

net use \\server1\ipc$ /user:user01 password
net use \\server2\ipc$ /user:user01 password
net use \\server3\ipc$ /user:user01 password
net use \\server4\ipc$ /user:user01 password
net use \\server5\ipc$ /user:user01 password

sc \\server1 stop w3svc >> output.txt
timeout /t 30
sc \\server1 stop httpfilter >> output.txt
timeout /t 30
sc \\server1 stop iisadmin >> output.txt
sc \\server1 stop tmproxy >> output.txt

sc \\server2 stop w3svc >> output.txt
timeout /t 30
sc \\server2 stop httpfilter >> output.txt
timeout /t 30
sc \\server2 stop iisadmin >> output.txt
sc \\server2 stop tmproxy >> output.txt


sc \\server3 stop w3svc >> output.txt
timeout /t 30
sc \\server3 stop httpfilter >> output.txt
timeout /t 30
sc \\server3 stop iisadmin >> output.txt
sc \\server3 stop tmproxy >> output.txt


sc \\server4 stop w3svc >> output.txt
timeout /t 30
sc \\server4 stop httpfilter >> output.txt
timeout /t 30
sc \\server4 stop iisadmin >> output.txt
sc \\server4 stop tmproxy >> output.txt


sc \\server5 stop w3svc >> output.txt
timeout /t 30
sc \\server5 stop httpfilter >> output.txt
timeout /t 30
sc \\server5 stop iisadmin >> output.txt
sc \\server5 stop tmproxy >> output.txt

Open in new window


You need to adjust timeout as your need, if it is too short the next statement will fail when the dependant  service is still stopping e.g. w3svc depends on httpfilter and httpfilter depends on iisadmin so if you want to stop iisadmin you need to stop w3svc httpfilter and iisadmin in order. so if you don't wait for w3svc to stop stopping httpfilter will throw error

You need to modify the file if there is any service depends on tmproxy, you need to stop that service before stopping tmproxy.
ASKER CERTIFIED SOLUTION
Avatar of achaldave
achaldave
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of samih_habib

ASKER

Thanks