+ Post New Thread
Results 1 to 8 of 8
Windows Server 2000/2003 Thread, Script to Restart Service in Technical; We have a server service which is rather temperamental, and periodically takes its ball home until you restart it. I ...
  1. #1
    enjay's Avatar
    Join Date
    Apr 2007
    Location
    Reading, Berkshire, UK
    Posts
    3,955
    Thank Post
    244
    Thanked 159 Times in 135 Posts
    Rep Power
    55

    Script to Restart Service

    We have a server service which is rather temperamental, and periodically takes its ball home until you restart it. I know how to use scripts/scheduled tasks to stop and start a service, but was wondering if it was possible to schedule a restart, or configure a pause into a command. Noob question, I know, but there you have it!

  2. IDG Tech News

  3. #2

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    7,028
    Thank Post
    1,088
    Thanked 641 Times in 598 Posts
    Rep Power
    209
    You can on the service properties set it to restart should it fail etc so that may be worth a shot short of that you could use wmi to stop and restart the service

    WMI and VBScript - Stop and Start Services with Win32_Service

  4. #3


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    3,493
    Thank Post
    134
    Thanked 473 Times in 412 Posts
    Rep Power
    149
    batch file where spooler is whatever service you want

    net stop spooler && net start spooler

    save that and stick it in task scheduler

  5. Thanks to sted from:

    enjay (23rd September 2009)

  6. #4
    enjay's Avatar
    Join Date
    Apr 2007
    Location
    Reading, Berkshire, UK
    Posts
    3,955
    Thank Post
    244
    Thanked 159 Times in 135 Posts
    Rep Power
    55
    Thanks Sted, that looks perfect. What if my service name has spaces in it - do I need quote marks, or just write it out normally?

  7. #5

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    7,028
    Thank Post
    1,088
    Thanked 641 Times in 598 Posts
    Rep Power
    209
    net stop "Service Name"

    net start "Service Name"

    Yes just put quotes around the service name and you can also use two ampersand symbols to make it do both commands one after the other
    Last edited by mac_shinobi; 23rd September 2009 at 02:29 PM.

  8. Thanks to mac_shinobi from:

    enjay (23rd September 2009)

  9. #6
    enjay's Avatar
    Join Date
    Apr 2007
    Location
    Reading, Berkshire, UK
    Posts
    3,955
    Thank Post
    244
    Thanked 159 Times in 135 Posts
    Rep Power
    55
    Thanks you two, that works a treat.

    Now I just need to wait for Capita to work out why I need to do this!

  10. #7


    Join Date
    Dec 2005
    Location
    In the server room, with the lead pipe.
    Posts
    3,797
    Thank Post
    203
    Thanked 568 Times in 441 Posts
    Rep Power
    172
    If you need more flexibility or querying of services, there's also the "sc" command.

  11. #8


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    3,493
    Thank Post
    134
    Thanked 473 Times in 412 Posts
    Rep Power
    149
    Quote Originally Posted by NickJones View Post
    Thanks you two, that works a treat.

    Now I just need to wait for Capita to work out why I need to do this!
    they expect users to do their testing as its cheaper is my guess

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 26
    Last Post: 15th December 2011, 05:05 PM
  2. restart system from startup script
    By spaterso in forum Windows
    Replies: 3
    Last Post: 30th July 2009, 08:27 PM
  3. Server Restart
    By Gibson335 in forum Hardware
    Replies: 8
    Last Post: 23rd January 2009, 10:40 AM
  4. VBS code to restart a service.
    By FN-GM in forum Scripts
    Replies: 4
    Last Post: 8th October 2008, 09:18 PM
  5. Restart when script completes
    By djones in forum Scripts
    Replies: 4
    Last Post: 18th May 2008, 10:26 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •