![]() |
#1 |
Junior Member
Join Date: Jul 2019
Posts: 30
|
Creating and starting Windows service using SimpleSC
Hi,
I am using SimpleSC::InstallService and StartService to create and start a windows service. However, I have noticed that the window hangs for few seconds ( 3-4s )during this process. It sometimes shows "Not Responding" I have tried another method using progress bar where the progress bar is displayed when the service installs and starts. There also I have noticed that the progress bar stops for some time. Below is the code SimpleSC::ExistsService "AGService" Pop $0 ${If} $0 != 0 DetailPrint "Installing AGWindowsService" SimpleSC::InstallService "MyService" "AGWindowsService" "16" "2" "$INSTDIR\winservice\MyWindowsService.exe" "" $R8 $R5 SimpleSC::SetServiceDescription "MyService" "This service is used to communicate with My Server" SimpleSC::SetServiceLogon "MyService" $R8 $R5 Pop $0 ; return error(1)/success(0) StrCmp $0 +1 Done ; If successful grant the service logon privilege to "MyServiceUser" SimpleSC::GrantServiceLogonPrivilege $R8 Pop $0 ; return error(1)/success(0) Done: DetailPrint "Starting AGWindowsService" SimpleSC::StartService "AGService" "" 30 SimpleSC::ServiceIsRunning "AGService" 1 30 Pop $0 Pop $1 ${if} $0 != 0 # error MessageBox MB_OK|MB_ICONSTOP "Unable to start service - Reason: $0" ${endif} ${if} $1 == 0 # service not running MessageBox MB_OK|MB_ICONSTOP "Unable to start service - Reason: $0" ${endif} ${Else} SimpleSC::RestartService "AGService" "" 30 ${EndIf} Please help!!! |
![]() |
![]() |
![]() |
#2 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,548
|
Ideally you should only perform these types of tasks in a Section. If you need to do it on a custom page you can try https://nsis.sourceforge.io/BgWorker_plug-in
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|