NSIS Simple Service Plugin

From NSIS Wiki
Jump to navigationJump to search

Links

GitHub repository - source code, documentation and issue tracker

Download the latest version (ANSI and Unicode builds)

Description

SimpleSC is an NSIS plugin to manage Windows services. It contains basic functions like installing, removing, starting or stopping a service and checking the service status, as well as advanced functions for example setting the service description, changing the logon account, configuring failure actions and granting or removing the service logon privilege.

Installation

  • ANSI build: copy SimpleSC.dll to Plugins\x86-ansi (NSIS 3) or Plugins (NSIS 2)
  • Unicode build: copy SimpleSC.dll to Plugins\x86-unicode (NSIS 3 with Unicode true)

Example

; Install a service - ServiceType own process - StartType automatic - NoDependencies - Logon as System Account
  SimpleSC::InstallService "MyService" "My Service Display Name" "16" "2" "C:\MyPath\MyService.exe" "" "" ""
  Pop $0 ; returns an errorcode (<>0) otherwise success (0)
 
; Start a service
  SimpleSC::StartService "MyService" "" 30
  Pop $0 ; returns an errorcode (<>0) otherwise success (0)
 
; Stop a service and waits for file release
  SimpleSC::StopService "MyService" 1 30
  Pop $0 ; returns an errorcode (<>0) otherwise success (0)
 
; Remove a service
  SimpleSC::RemoveService "MyService"
  Pop $0 ; returns an errorcode (<>0) otherwise success (0)

The complete function reference with all parameters and examples is available in the README on GitHub.

Questions and bug reports

Please use the issue tracker on GitHub.