Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to manage Windows services from MSSQL ?

Posted on 2011-10-27
8
Medium Priority
?
271 Views
Last Modified: 2012-05-12
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 ?
0
Comment
Question by:exceter
  • 5
  • 3
8 Comments
 
LVL 15

Expert Comment

by:Anuj
ID: 37042851
Query to start Service in SQL Server
xp_cmdshell 'NET START <Servicesname>
0
 
LVL 3

Author Comment

by:exceter
ID: 37043029
What about to do this on remote computer?
0
 
LVL 15

Expert Comment

by:Anuj
ID: 37043042
did you tried
xp_cmdshell 'sc \\remoteMachine Start<service>'
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 3

Author Comment

by:exceter
ID: 37043611
>> xp_cmdshell 'sc \\remoteMachine Start<service>'
How and where to put username+password ? I cant figure it out
0
 
LVL 15

Accepted Solution

by:
Anuj earned 2000 total points
ID: 37043625
xp_cmdshell 'sc \\RemoteMachine start<Service> obj=<username> password = <password>'

DisplayName=(string)
A string that can be used by user-interface programs to identify the service.

password=(string)
0
 
LVL 15

Expert Comment

by:Anuj
ID: 37043626
Refer this for SC command
0
 
LVL 3

Author Comment

by:exceter
ID: 37055091
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
0
 
LVL 15

Expert Comment

by:Anuj
ID: 37055096
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.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question