esi-ntservice

A library that supplies helper methods for using the sc.exe command (windows services)

Changes

version date description

1.72.0

2020-12-08

TFS code synchronisation

1.0.0

2020-10-21

Initial release

Dependencies

library version inmation core library

esi-string

1.0.4

yes

Available functions

All functions have to be called according to the ESI standard, using colons, e.g. lib:FUNCTIONNAME(params)

Documentation

Most methods below have 2 optional parameters:

Parameter Description

logFunction

Callback function with single parameter of type string

waitTime

Additional time to wait in seconds after call to sc.exe or popen.

EXEC

EXEC(cmd, logFunction, waitTime)

A wrapper around the Lua popen command

GET_ENV

GET_ENV(variableName)

Return the value of an environment variable. If the provided VariableName does not exist, an invalid string will be returned.

SC_QUERY

SC_QUERY(serviceName, logFunction)

Wrapper around the system sc.exe query command.

SC_EXISTS

SC_EXISTS(serviceName, logFunction)

Check if service exists (sc.exe query), returns true if it does exist.

SC_STOP

SC_STOP(serviceName, logFunction, waitTime)

Wrapper around the system sc.exe stop command.

SC_START

SC_START(serviceName, logFunction, waitTime)

Wrapper around the system sc.exe start command.

SC_RESTART

SC_RESTART(serviceName, logFunction, waitTime)

Tries to restart service by calling net stop "{serviceName}" && net start "{serviceName}".

SC_SERVICES

SC_SERVICES()

Uses sc query to return Lua table with all services on the system.

SC_CONFIG

SC_CONFIG(serviceName, paramString, logFunction, waitTime)

Wrapper method around the system sc.exe config command. Can be used to configure service parameters. paramString allows to specify service parameters, like startup type or user/password.

The available value allowed for paramString are explained here.

TASKLIST

TASKLIST(variableName)

Wrapper around the system tasklist command.