Starting and stopping service with a script

  • I need to write a script that will start and then a script to stop the sql server.

    I am not sure how to go about this. I am using msde and I am using it on a Windows small business server 2000.

    Any help

     

    Kevin

  • have a look at the sc command


    * Noel

  • SC ? Is that a SBS server comand, or SQL - I'm kinda interested as well ....

  • NET stop yourservice

    NET start yourservice

    will also you the trick if you're authorised.

    p.s. even with msde you can make regular sql-backups,

        so there is no sql-need to stop-start the service !

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • One is ponder the potential to create a central server that control an environemnt, eg dev/test, that could use such commands to shut down server's, etc.

    Not sure if it would be possible - maybe via a batchfile run for the controlling server, from an XP_CMDSHELL, to shut down SQL on target server. I have also seen commands like:

    iisreset /stop

    net stop "service"  <---- just realized this is what you posted

    complusreset

     

    So I could potentially shut everything down on the box, maybe automate the rollout of code to the box, start up the service's, restore databases and gnerally roll out an environment. Hmmmm....

  • sc.exe has been around since NT 4 in the Resource Kits. I think it's now included in XP and 2003. It'll allow you to handle services both locally and remotely. The issue with the net commands is that they must be run local to the computer in question. Two workarounds: use of the AT command (provided Task Scheduler is running on the remote computer) and the use of a tool like psexec from SysInternals.

    K. Brian Kelley
    @kbriankelley

  • I use psexec to stop/start services on remote machines.  You just need to make sure you have permissions to do it. http://www.sysinternals.com/ntw2k/freeware/psexec.shtml

     

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply