Reputation: 33
I want to run a service using NSSM, doing so from Command Prompt (ran as administrator) works. Commands used in command prompt are:
# Command Prompt commands
C:\Windows\system32>cd C:\Users\D-002\Downloads\nssm-2.24\win64
C:\Users\D-002\Downloads\nssm-2.24\win64>
nssm install TestService "C:\Program Files (x86)\CodeBlocks\Testing Projects\TestServiceProgram\bin\Debug\TestServiceProgram.exe"
Service "TestService" installed successfully!
But I want to achieve same functionality using NSIS. Running following script doesn't create TestService.
# NSIS script
; name the installer
OutFile "Installer.exe"
; default section start; every NSIS script has at least one section.
Section
;nssm folder is placed in same folder where Installer.exe is created
ExecWait 'cd "$EXEDIR\nssm\win64"'
ExecWait 'nssm install TestService "$EXEDIR\TestServiceProgram.exe"'
; default section end
SectionEnd
As I have no prior knowledge of NSIS, if anybody could indicate, what I am doing wrong or missing ?
Upvotes: 0
Views: 1083
Reputation: 138
Check if the service is created into service list. Are created but not running?
If is created but not running remember that Services are executed with System32 as working directory and here you must place eventually config file.
You can install service with SimpleSC plugin (http://nsis.sourceforge.net/NSIS_Simple_Service_Plugin):
Here my code:
Section "Install Service"
SimpleSC::ExistsService "MyService" ;
MyService
pop $0
${If} $0 == "0" ;
SimpleSC::StopService "MyService"
DetailPrint "Service found"
${Endif}
DetailPrint "Installing My"
SimpleSC::InstallService "MyService" \
"My Service Description" \
16 \
2 \
"$ServiceFolder\MyService.exe" \
"" \
"" \
"" \
""
SimpleSC::SetServiceDescription "MyService" "MyService description"
DetailPrint "Installation of MyService completed"
SimpleSC::StartService MyService"
DetailPrint "Service started."
SectionEnd
Upvotes: 1