View Single Post
Old 25th February 2021, 11:35   #1
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 33
can SimpleSC::GetErrorMessage be used outside the function or macro it is called?

using NSIS Simple SC plugin i am trying to manipulate services and get return value. however i am not able to use Get Error message outside a function or macro. is it possible.. below is my sample code

!macro ServiceStop serviceName Timeout
Push $0
Push $1
SimpleSC::ExistsService "${ServiceName}"
Pop $0
${If}
$0 = 0
SimpleSC::GetServiceStatus "${serviceName}"
${If} $0 == 0
${If} $1 != 1
SimpleSC::StopService "${serviceName}" 1 ${Timeout} ; 1 - wait 60 - timeouts in secs
Pop $0
${Endif}
${Endif}
${Endif}
Pop $1
Exch $0
!macroend

Function GetServiceErrorReturnCode
ClearErrors
Exch $0
${If} $0 != 0
Push "0 not equal 0. service action returned $0 ."
Push $0
SimpleSC::GetErrorMessage
Pop $0
${Endif}
Pop $0
FunctionEnd

!macro GetServiceErrorReturnCode RetCode
Push "${RetCode}"
Call GetServiceErrorReturnCode
!macroend Section

!insertmacro ServiceStop "SN" 10
Pop $0
${If} $0 != 0
!insertmacro GetServiceErrorReturnCode $0
MessageBox MB_OK "$0"
${Endif}
SectionEnd
shekara is offline   Reply With Quote