Remote services question

  • I can't get a remote service to stop using

    sc \\server stop service in a batch file, from sql query analyzer, etc. Of course it runs with no problem locally.

    And I would also like to run the command with an Execute As, which is a domain user on the remote box.

    Any ideas?

    thx

    jude

  • Kindly post the error.

    Mj

  • If there are dependent services it may be waiting for you to press "y" to say stop those dependent services.

    Also, what problem are you trying to solve with this? Starting stopping services would seem to be something that could be handled better outside SQL.

    CEWII

  • I am actually trying to stop a service on a remote server to do a restore on the sql server. I found psservice & downloaded it & it works great from the cmd line/window, but I cannot seem to get it to work in a sql scheduled job. I've tried using xp_cmdshell to execute a .bat file & am just at a loss for what syntax can be used to get psservice to work inside my sql scheduled job (Sql server 2005)

    Psservice & .bat files reside on both servers in question.

  • What error do you get?

    CEWII

  • I am curious why you need to use sql server to stop this service. I am also curious what service is being stopped and what is being restored.

    These are typically not the kinds of things one does from within SQL Server (stop service). If it is an application service that ties into the remote SQL database, I could almost buy that - but then again applications on the same box as the database make me ponder...

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • I need to stop the service to do the restore. This application, Warehouse Management System, keeps the services running & if I kill these connections to the sql server, they just restart. If I stop the service on the other box by using my .bat file from the cmd line, all is well. If I use the same .bat file on the server where the application exists, also no problem. It just doesn't execute in my scheduled job.

    Error Message is that the proxy account cannot be found & I am not familiar with how to fix this issue.

  • Is your job owner an non-sysadmin account? Try changing it tosa and see if it works.

    MJ

  • The account used to drop the service on the remote server is a non-sysadmin. But when I execute the .bat on that server with that acct. all is well.

    I found an article by Tibor Karaszi & this is what I tried;

    EXEC sp_xp_cmdshell_proxy_account 'domain\WinUser', 'pwd'

    Execute as login = 'x'

    Exec Xp_cmdshell 'c:\stopremoteservice.bat' (This batch file uses psservice)

    The query runs, but it just hangs & the service on the remote box isn't stopping.

    Any more ideas?

Viewing 9 posts - 1 through 8 (of 8 total)

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