Windows 7: How to stop/start service from commandline (like services.msc does it)?
Posted
by
john
on Server Fault
See other posts from Server Fault
or by john
Published on 2011-07-13T08:03:01Z
Indexed on
2012/11/01
11:03 UTC
Read the original article
Hit count: 167
I have developed a program in Java that uses on a local SQL Server instance to store its data. On some installations the SQL Server instance is not running sometimes.
Users can fix this problem by manually starting the SQL Server instance (via services.msc).
I am thinking about automating this task: the software would check if the database server is reachable, if not try to (re)start it. The problem is that on the same user account the Services can be stopped /started via services.msc (without any UAC prompt), but not via (non-elevated) command line.
The operating system seems to treat services.msc differently:
c:\>sc start mssql$db1
[SC] StartService: OpenService FEHLER 5:
Zugriff verweigert (Access denied)
c:\>net start mssql$db1
Systemfehler 5 aufgetreten. Zugriff verweigert (Access denied)
So the question is: how can I stop/start the service from a java-program/command line without having my users to use services.msc (preferrably via on-board-tools)
© Server Fault or respective owner