![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Windows NT/2000/2003 Server/2008 Server Find support for Windows NT/2000/2003 Server/2008 Server editions. |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Sep 2008
Posts: 6
OS: win2003
|
Restart service/s on a remote server
Hi All,
I am looking at a script which can restart a microsoft service on a remote windows 2003 server. I should be able to execute the script from the comfort of my notebook, thus by entering all required information like username, password and domain name within the script. Please let me know is there any script to do the above functionality. Thanks in advance. Best Regds Farooq |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) |
|
Registered User
Join Date: Sep 2008
Posts: 6
OS: win2003
|
Re: Restart service/s on a remote server
Hi All,
I got the below script which is working fine on my local machine, but same functionality i want to have on a remote server, ie if i click from my desktop , i should be able to stop/start the service on a remote server. Option Explicit Dim objWMIService, objItem, objService Dim colListOfServices, strComputer, strService, intSleep strComputer = "computerName" intSleep = 15000 WScript.Echo " Click OK, then wait " & intSleep & " milliseconds" 'On Error Resume Next ' NB strService is case sensitive. strService = " 'Alerter' " Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2") Set colListOfServices = objWMIService.ExecQuery _ ("Select * from Win32_Service Where Name ="_ & strService & " ") For Each objService in colListOfServices objService.StopService() WSCript.Sleep intSleep objService.StartService() Next WScript.Echo "Your "& strService & " service has Started" WScript.Quit ' End of Example WMI script to Start / Stop services your help greatly appreciated. Best Regds Farooq |
|
|
|
|
|
#4 (permalink) |
|
Registered User
Join Date: Sep 2008
Posts: 6
OS: win2003
|
Re: Restart service/s on a remote server
Hi Krrose27,
I am a portal(SAP) consultant and i dont know anything about scripting :-(. Can you give some more details to implement the restart of particular service from my laptop. Also with vnc i think we need to connect to server from the local machine and then perform the restart manually, my idea is to give this script to some one who do not understand anything about the restart of service, but his job is to run the file locally whenever some problem occurs, and restarting the service on remote server is a workaround for some issue what i am facing. Let me know if you/any one has the solution for this. Best Regds Farooq |
|
|
|
|
|
#5 (permalink) |
|
Registered User
Join Date: Aug 2008
Location: Glasgow
Posts: 39
OS: Multiple
|
Re: Restart service/s on a remote server
Hey
You can use various tools to do this, best not to overcomplicate it I find. I use either CPAU or psservice (from sysinternals) You can just create a .bat using standard windows commands as well. have the command running from a batch file using psservice would work quite well for yourself. The command would be something like.... psservice \\server -u domain\username -p password stop service name psservice \\server -u domain\username -p password start service name Maybe this will help. Let me know if you want more info. |
|
|
|
|
|
#6 (permalink) |
|
Registered User
Join Date: Sep 2008
Posts: 6
OS: win2003
|
Re: Restart service/s on a remote server
Hi GraemeI,
Thanks a lot for your timely help, the batch file or direct command is working perfectly. Once again thanks a ton. How ever, my service takes time to stop, may be some 10 seconds, i wanted to know whether i can provide any time delays between stop and start commands within a batch file. Best Regds Farooq |
|
|
|
|
|
#7 (permalink) |
|
Registered User
Join Date: Aug 2008
Location: Glasgow
Posts: 39
OS: Multiple
|
Re: Restart service/s on a remote server
You're very welcome.
If you do not already have the resource kit tools download them as they are really useful linky and just use sleep N (n representing number of seconds) to delay whatever you want. |
|
|
|
|
|
#8 (permalink) |
|
Registered User
Join Date: Sep 2008
Posts: 6
OS: win2003
|
Re: Restart service/s on a remote server
Hi GraemeI,
I gave the command like this (in a batch file) psservice \\serverName -u domain\username -p password stop Alerter sleep 1500 (or psservice sleep 15) psservice \\serverName -u domain\username -p password start Alerter but the sleep command is not working. Any help? Best Regds Farooq |
|
|
|
|
|
#9 (permalink) |
|
Registered User
Join Date: Sep 2008
Posts: 6
OS: win2003
|
Re: Restart service/s on a remote server
Hi Graeme,
Any update on how to make the delay working in below command(batch file). If any one can let me know how to insert delay between stop and start of the service.(See my earlier post). Thanks in advance Best Regds Farooq |
|
|
|
|
|
#10 (permalink) |
|
Registered User
Join Date: Aug 2008
Location: Glasgow
Posts: 39
OS: Multiple
|
Re: Restart service/s on a remote server
Hi Farooq,
Studying and working to much just now. Did you have any problems getting the resource kit tools for server 2003 from the link on my last post. If not what happens when you type sleep or sleep.exe into a command prompt from the machine you are running the script from? |
|
|
|
![]() |
| Thread Tools | |
|
|