Link to home
Start Free TrialLog in
Avatar of exceter
exceterFlag for Kyrgyzstan

asked on

How to manage Windows services from MSSQL ?

Hi,
I need to start/stop/restart Windows services from MSSQL 2000.
As I know it is a "sc" command, but I was unsuccessful. It runs a long time without needed result.

Could you show an example ?
Avatar of Anuj
Anuj
Flag of India image

Query to start Service in SQL Server
xp_cmdshell 'NET START <Servicesname>
Avatar of exceter

ASKER

What about to do this on remote computer?
did you tried
xp_cmdshell 'sc \\remoteMachine Start<service>'
Avatar of exceter

ASKER

>> xp_cmdshell 'sc \\remoteMachine Start<service>'
How and where to put username+password ? I cant figure it out
ASKER CERTIFIED SOLUTION
Avatar of Anuj
Anuj
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Refer this for SC command
Avatar of exceter

ASKER

I always get the following error message:
>sc \\192.168.200.102 stop SharedAccess obj="administrator" password="1q2w3e$R"
[SC] OpenSCManager FAILED 5:

Access is denied.

Tried on XP, Windows 7, 2008
If this is working on your local machine then the problem is that your sql server service account does not have the rights to login to the remote server.