+ 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
    4,485
    Thank Post
    282
    Thanked 196 Times in 167 Posts
    Rep Power
    75

    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. #2

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,680
    Thank Post
    3,210
    Thanked 1,030 Times in 955 Posts
    Rep Power
    361
    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

  3. #3


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,506
    Thank Post
    227
    Thanked 848 Times in 727 Posts
    Rep Power
    287
    batch file where spooler is whatever service you want

    net stop spooler && net start spooler

    save that and stick it in task scheduler

  4. Thanks to sted from:

    enjay (23rd September 2009)

  5. #4
    enjay's Avatar
    Join Date
    Apr 2007
    Location
    Reading, Berkshire, UK
    Posts
    4,485
    Thank Post
    282
    Thanked 196 Times in 167 Posts
    Rep Power
    75
    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?

  6. #5

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,680
    Thank Post
    3,210
    Thanked 1,030 Times in 955 Posts
    Rep Power
    361
    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.

  7. Thanks to mac_shinobi from:

    enjay (23rd September 2009)

  8. #6
    enjay's Avatar
    Join Date
    Apr 2007
    Location
    Reading, Berkshire, UK
    Posts
    4,485
    Thank Post
    282
    Thanked 196 Times in 167 Posts
    Rep Power
    75
    Thanks you two, that works a treat.

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

  9. #7


    Join Date
    Dec 2005
    Location
    In the server room, with the lead pipe.
    Posts
    4,619
    Thank Post
    275
    Thanked 777 Times in 604 Posts
    Rep Power
    223
    If you need more flexibility or querying of services, there's also the "sc" command.

  10. #8


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,506
    Thank Post
    227
    Thanked 848 Times in 727 Posts
    Rep Power
    287
    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, 04: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, 09: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
  •