Old 5th December 2020, 04:00   #1
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 6
using nsis i need to start a disabled service

using I am try to start a service which is in disabled state and not started.
I am using simple SC plugin to achieve this. if the service is not disabled, I can start it.
but when it is disabled , it fails.

i have tried using SimpleSC::SetServiceStartType "service name" "2". but it has failed
shekara is offline   Reply With Quote
Old 5th December 2020, 16:04   #2
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 6
when the service is set to manual or disabled, i am having issues. if it is set to automatic, it works
shekara is offline   Reply With Quote
Old 5th December 2020, 16:18   #3
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 6
the issue is same when i try o stop a service which is set to manual
shekara is offline   Reply With Quote
Old 5th December 2020, 16:26   #4
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 6
!define ServiceStop `!insertmacro ServiceStop`
!macro ServiceStop SVC stopTime StopSer
Push $0
Push $1
Push ${StopSer}
SimpleSC::ExistsService "${SVC}"
Pop $0
${If} $0 == 0
MessageBox MB_OK "${SVC} exists $0"
SimpleSC::GetServiceStartType "${SVC}"
Pop $0 ; returns an errorcode (<>0) otherwise success (0)
Pop $1 ; returns the start type of the service
MessageBox MB_OK "${SVC} start type $1. 4 is disabled, 2 is autostart"
${If} $1 == 4
${OrIf} $1 != 2
${OrIf} $1 != 3
#SimpleSC::SetServiceStartType [name_of_service] [start_type]
SimpleSC::SetServiceStartType "${SVC}" "2"
Pop $0 ;returns an errorcode (<>0) otherwise success (0)
MessageBox MB_OK "${SVC} SetServiceStartType $0"

SimpleSC::GetServiceDelayedAutoStartInfo "${SVC}"
Pop $0 ; returns an errorcode (<>0) otherwise success (0)
Pop $1 ; returns the delayed auto-start configuration
MessageBox MB_OK "${SVC} GetServiceDelayedAutoStartInfo $1"
${If} $1 == 1
SimpleSC::SetServiceDelayedAutoStartInfo "${SVC}" "1"
${EndIf}
${Endif}

SimpleSC::GetServiceStatus "${SVC}"
Pop $0
Pop $1
${If} $1 != 1
${OrIf} $1 = 4
MessageBox MB_OK "${SVC} service status is $1"
SimpleSC::StopService "${SVC}" ""
Pop $0
Pop $1

MessageBox MB_OK " stop service type value is 0 is $0 is $1"
Exch $0
Pop ${StopSer}
MessageBox MB_OK " Exch value is $0 amd StopSer is ${StopSer}"
${Endif}
${Else}
Return
${Endif}
Pop $1
Exch $0
!macroend

!insertmacro ServiceStop "GoogleChromeElevationService" 30 $0
Pop $0
MessageBox MB_OK "$0"
${If} $0 != 0
MessageBox MB_OK "ERROR = Unable to stop GoogleChromeElevationService Service"
Abort
${Else}
MessageBox MB_OK "GoogleChromeElevationService service stop successfully"
${EndIf}
shekara 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