rutgermons
asked on
batch to shutdown windows services
Folks
How can I create a batch that can logon to 2 or 3 different servers which invoke a command to shutdown 5 windows servers on each server ? in addition, I would like to specify the stop order in the batch but also ensure between stopping each service that there is a 60 second wait period between stopping the next
all help will do
How can I create a batch that can logon to 2 or 3 different servers which invoke a command to shutdown 5 windows servers on each server ? in addition, I would like to specify the stop order in the batch but also ensure between stopping each service that there is a 60 second wait period between stopping the next
all help will do
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi, all the above is good, but you will also have to add the option to psexec to accept the eula if you run it within a batch file and point it to other servers. Just start the command for psexec this way:
and add the addtional commands and options as needed.
example using other expert's excellent post:
Good Luck,
- gurutc
psexec /accepteula
and add the addtional commands and options as needed.
example using other expert's excellent post:
psexec /accepteula @C:\Scripts\Servers.txt -c c:\Scripts\StopServices.cmd -v -s -d
Good Luck,
- gurutc
You only have to accept the EULA once on the machine running psexec, so that isn't a big issue, but yes, it is a good idea to always add that switch.
We've seen it happen when pointing to other servers. psexec actually temporarily installs itself on the remote system as a service and then executes the remote commands. Since the remote system's never run psexec it fails silently because of the eula.
It's one of those 'sometimes it works, sometimes it don't' things.
- gurutc
It's one of those 'sometimes it works, sometimes it don't' things.
- gurutc
http://technet.microsoft.com/en-gb/sysinternals/bb897553.aspx
PsExec can be used to run any commands on remote servers. The only thing you might have issue with is the waiting 60 seconds. Although I believe the Windows 2003 resource kit (again a free download) has a sleep.exe command that can be used to pause a script:-
http://www.microsoft.com/en-gb/download/details.aspx?id=17657
OR this free alternative-
http://www.sleepcmd.com/