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:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* 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
Go Back   Tech Support Forum > Microsoft Support > Windows NT/2000/2003 Server/2008 Server
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Windows NT/2000/2003 Server/2008 Server Find support for Windows NT/2000/2003 Server/2008 Server editions.

Reply
 
LinkBack Thread Tools
Old 09-05-2008, 01:48 AM   #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
farooq_rcr is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
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

Old 09-05-2008, 11:43 AM   #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
farooq_rcr is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-05-2008, 11:45 AM   #3 (permalink)
Registered User
 
Join Date: Jul 2008
Posts: 38
OS: Serv 03 R2 SP2, Mac Os X 10.5.4, XP Pro SP2, XP Home SP2, Ubuntu


Re: Restart service/s on a remote server

why not use rdc or vnc to performe this directly on the machine?
Krrose27 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-05-2008, 04:03 PM   #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
farooq_rcr is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-07-2008, 09:10 AM   #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.
GraemeI is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-07-2008, 01:13 PM   #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
farooq_rcr is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-07-2008, 02:58 PM   #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.
GraemeI is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-08-2008, 10:34 AM   #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
farooq_rcr is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-11-2008, 12:40 AM   #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
farooq_rcr is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-11-2008, 08:25 AM   #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?
GraemeI is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 09:57 PM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85