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)

link|improve this question
1  
You have to elevate the prompt itself or it will not work. That, or change UAC appropriately, or try the PowerTools for this purpose as others have. – alharaka Jul 13 '11 at 10:18
feedback

1 Answer

Perhaps you can set the right privileges using the sc.exe command. See this MSDN article for details.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.