Avatar of samih_habib
samih_habib
Flag 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
Windows Server 2003

Avatar of undefined
Last Comment
samih_habib

8/22/2022 - Mon
achaldave

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
achaldave

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
samih_habib

ASKER
Thanks
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy