i have created .nsh file using SIMPLE SC to start, stop and remove services. i have used macros for this.
#SimpleSC::StartService [name_of_service] [arguments] [timeout]
!define Service::Start `!insertmacro Service::Start`
!macro Service::Start SVC Args Timeout
Push $0
Push $1
SimpleSC::ExistsService "${SVC}"
Pop $0
${If} $0 == 0
SimpleSC::GetServiceStatus "${SVC}"
Pop $0 ;error code
Pop $1 ;service status
${If} $0 == 0
${AndIf} $1 != 4
SimpleSC::StartService "${SVC}" "${Args}" "${Timeout}"
Pop $0
${Endif}
${Endif}
Pop $1
Pop $0
!macroend
When i call this in msu nsi file it works. But i would like to know the return value for start service (SimpleSC::StartService "${SVC}" "${Args}" "${Timeout}", Pop $0). howdo i retrive the $0 value of nsh file in my nsi file
retrieve variable value from nsh file
2 posts
The return code from SimpleSC::StartService is in $0, so at the end of the macro change 'Pop $0' to "Exch $0". Then after you have called ${Service::Start}, use 'Pop' to get the return code. The documentation says that 0 is success, any other number is an error.