Old 23rd October 2020, 05:05   #1
Junior Member
Join Date: Oct 2020
Posts: 6
retrieve variable value from nsh file

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


Pop $1
Pop $0

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
shekara is offline   Reply With Quote
Old 24th October 2020, 08:57   #2
Major Dude
JasonFriday13's Avatar
Join Date: May 2005
Location: New Zealand
Posts: 901
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.

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump