News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Start service and restart as admin

Started by mabdelouahab, April 29, 2016, 02:36:54 AM

Previous topic - Next topic

mabdelouahab

I'm working on completing work with Sql Server, In the meantime I've encountered a problem: How can I make sure that customer service works
And how do I restarted if stoped
Also, This requires that the program must running as administrator
I made this program to make sure that it works well in all conditions
I suggested : "Audiosrv" Windows Audio Service; you can work on any other service.
ServiceName EQU BSTR$("Audiosrv") ;Just for test: Windows Audio Service

Also you can choose a .Net version
; CLR = 2 For .Net 2/2.5/3/3.5
; CLR = 4 For .Net 4/4.5

__ClrVersion EQU 2 ; 4

mabdelouahab

If no error occurs, it will be as follows:
The first run:

Quote
The program needs to run As Administrator
Press any key to continue ...

the second run:
Quote

Audiosrv Service is  Running
wait for Stop the service
Press any key to continue ...

Audiosrv Service is Not Running
wait for running the service
Press any key to continue ...

fearless

Could use the win32 service manager functions:

OpenSCManager: https://msdn.microsoft.com/en-us/library/windows/desktop/ms684323%28v=vs.85%29.aspx
OpenService: https://msdn.microsoft.com/en-us/library/windows/desktop/ms684330%28v=vs.85%29.aspx
QueryServiceStatus: https://msdn.microsoft.com/en-us/library/windows/desktop/ms684939%28v=vs.85%29.aspx for SERVER_STATUS (https://msdn.microsoft.com/en-us/library/windows/desktop/ms685996%28v=vs.85%29.aspx)
and NotifyServiceStatusChange https://msdn.microsoft.com/en-us/library/windows/desktop/ms684276%28v=vs.85%29.aspx for when a server stops and you want to try and restart it perhaps?