Old 23rd October 2020, 05:05   #1
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 1
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

${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
shekara is offline   Reply With Quote
Old 24th October 2020, 08:57   #2
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 893
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)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Reply
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