Connecting to 5 different remote windows 2004 servers

samih_habib
samih_habib used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
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.
you can also use

wmic /node:server /user:user01 /password:password service w3svc

Author

Commented:
Thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial