October 14, 2009 at 9:23 am
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
October 14, 2009 at 3:47 pm
Kindly post the error.
Mj
October 14, 2009 at 3:55 pm
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
October 14, 2009 at 4:13 pm
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.
October 14, 2009 at 4:21 pm
What error do you get?
CEWII
October 14, 2009 at 4:25 pm
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
October 16, 2009 at 7:49 am
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.
October 16, 2009 at 12:34 pm
Is your job owner an non-sysadmin account? Try changing it tosa and see if it works.
MJ
October 16, 2009 at 1:08 pm
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