xp_servicecontrol

  • Hi there,

    can anybody help me with details on how to use xp_servicecontrol?

    I've figured out the first parameter could be 'start', 'stop', or 'pause'. Any more?

    Then second parameter is the Service name. The same as appears in the control panel?

    Any thoughts are appreciated!

    Cheers,

    Frank

    Well, obviously, if there is a 'pause' command there must be something like 'go on' or continue', right?

    Edited by - a5xo3z1 on 07/30/2003 12:37:52 AM

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Here you go.

    Parameter 1 can be any of the following.

    start

    stop

    pause

    continue

    querystate (Almost forgot that one as noted in previous posters post).

    Parameter 2 is the Service Name.

    For example "FTP Publishing Service" is MSFTPSVC.

    Unlike NET command line you cannot substitute the Display Name.

    Edited by - antares686 on 07/30/2003 04:48:13 AM

  • I belive there's also 'continue' and 'querystate'.

    An alternative might be xp_cmdshell combined with the (documented) sql "scm" command prompt utility.

    ...although the undocumented stuff is always more interesting.

    Cheers,

    - Mark


    Cheers,
    - Mark

  • quote:


    start

    stop

    pause

    continue

    querystate (Almost forgot that one as noted in previous posters post).

    Parameter 2 is the Service Name.

    For example "FTP Publishing Service" is MSFTPSVC.


    thank you both!

    Any secret fountain of wisdom, Antares, you might want to share?

    Now, the more interesting one.

    I execute this with sa permission.

    Am I able to start, stop.. services on that machine, although I am not NT admin to this box?

    Of course, this is only for security reasons

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • No secret there. I just ran it on my testbox here to see what happens when. The only thing that is confusing is that it gives the following error

    Server: Msg 22003, Level 16, State 1, Line 0
    
    StartService() returned error 997, 'Overlapped I/O operation is in progress.'

    when it is already in the state you are trying to make it.

    Also, yes SA can use it to stop and start services but don't tell the OS Admin guys, they would flip.

    In addition I seem to recall a few years ago something about SQL having this setup with Public having execute rights but a later patch changed. You might want to check just in case and remove that right. DOes anyone else recall the details on this?

  • If MSSQLSERVER is running under an admin account you certainly can.

    Reminds me of the time I used it (for security purposes) to stop sqlserveragent, start sqlserveragent, stop dhcp, start dhcp, stop mssqlserver..... oops

    Cheers,

    - Mark


    Cheers,
    - Mark

  • quote:


    No secret there. I just ran it on my testbox here to see what happens when. The only thing that is confusing is that it gives the following error


    lucky one!

    My testbox is SQL7. I was told for some good reasons, I can't remember right now!

    quote:


    In addition I seem to recall a few years ago something about SQL having this setup with Public having execute rights but a later patch changed. You might want to check just in case and remove that right. DOes anyone else recall the details on this?


    I have seen something on http://www.sqlsecurity.com/DesktopDefault.aspx?tabindex=3&tabid=4 . Also, when you google on this topic, you will find some very interesting ppt's from M$. Unfortunately in some asian language

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • quote:


    If MSSQLSERVER is running under an admin account you certainly can.

    Reminds me of the time I used it (for security purposes) to stop sqlserveragent, start sqlserveragent, stop dhcp, start dhcp, stop mssqlserver..... oops


    that's basically what I thought of!

    I have no remote or direct access to that box and hate to call the OS admins to start the SQL Server agent once it has died for some reasons.

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • quote:


    If MSSQLSERVER is running under an admin account you certainly can.

    Reminds me of the time I used it (for security purposes) to stop sqlserveragent, start sqlserveragent, stop dhcp, start dhcp, stop mssqlserver..... oops

    Cheers,

    - Mark


    Yeah, I have to try one running under Local System Account but I gotta run so don't have time to test.

    And don't feel bad. We use NetOp, PCDuo and Terminal Services and I'll be darned if when working with a few boxes I needed to disable the NIC and Reenable for testing. But for some reason disable stops everything from working for me.

  • On the same Note, I need to use the "SCM" command line tool to determine if the Service Manager is started during an Installation program. For some reason, the only thing I can get the thing to return to me is...absolutely nothing and an Error. It always tells me it's not running, even when it is! Also, I could not use the SCM to start the Service either.

    NOTE: I am using InstallShield Dev 7.2

  • Is this undocumented SP still present in the SP3 of SQL 2005/?

    If so, which DB?

    John

Viewing 11 posts - 1 through 10 (of 10 total)

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