Restart a Service on a Remote Computer
Hi
I am looking for a way to automatically stop and restart a service on another server if the one server is ever rebooted. I'm running W2K3 and W2K8 Server.
Is there a way to set this up or do I need to create a script that will run on the main server and will trigger the restart of the service on the other computer on startup when/if main server is ever rebooted.
Thanks, Estifan
December 28th, 2010 10:13pm
There are several ways:
1.
You can run the following commands in Windows PowerShell:
(gwmi -computername remotepc -class win32_service “Name=’alerter’”).stopservice()
(gwmi -computername remotepc -class win32_service “Name=’alerter’”).startservice()
Or use the following powershell script file:
Restart-Service Remotely
2.
You can use sc.exe to interact with local and remote services, schedule a task to run a batch file like:
Sc
\\server stop service
Sc
\\server start service
3.
Use psservice.exe tool to do the job, please refer to:
How To Stop And Start Services
On Remote Windows Computers
Please note:
we provide the above third party links for technical reference. There might be some changes without notice, Microsoft doesn’t guarantee any
accuracy on contacting information.
Best Regards
DalePlease remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Free Windows Admin Tool Kit Click here and download it now
December 29th, 2010 2:46am
Hi,
I was aware of option 2 and tried, it didn't work:
When I logon to machine A and run the shutdown batch (C:\WINDOWS\system32\GroupPolicy\Machine\Scripts\Shutdown\...) to stop services on machine B, it works fine, but when I reboot the machine A, I receive: [SC] OpenService FAILED 5: Access is denied.
Will investigate option 1 and 3
Thanks,
Estifan
December 30th, 2010 2:08pm
Hey, Estifan, how it works? Any update?
Best Regards
DalePlease remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Free Windows Admin Tool Kit Click here and download it now
January 2nd, 2011 8:26pm
Hi,
I tried option 3:
PsService.exe \\server -u uuuuuu -p ppppppp STOP service1 > C:\WINDOWS\system32\GroupPolicy\Machine\Scripts\Shutdown\shutdown.log
1)
when i execute the command n dos prompt, it works fine,
2)
when I run the batch job contains a.m. command it works fine.
3)
but when I reboot the server, nothing happens (even nothing in the shutdown.log)
so far option 2 and 3 did work when i am logged on to server A, but not when I reboot the server.
thanks,
Estifan
January 4th, 2011 9:25pm