The mksrv utility lets you run any program or script as a service.
To set up a program or script to run as a service, you must first use
mksrv with the
By default, when no
When specifying the command_line to be cached, you may need to quote the arguments passed at the end of the command line using normal quoting rules for the shell in use. For example:
mksrv -install -name MyService -displayname "My Service" -desktop "sh -c 'cd/tmp;ls'"
Once a service has been set up by the svsh utility, it can be started and stopped as desired with the MKS Toolkit control panel applet or with the service utility by referring to it using either the service or display name.
When a mksrv-created service is stopped (for example, with the service stop command), the child process for the service itself is killed, but any children created by that process are not.
Runs the service in debugging mode. In debugging mode, the service is run with a console window that lets you interact with it.
Tells the Windows Service Control Manager to let the service interact with the desktop through a console window. This option cannot be used with the
-usernameoption; only the local system account may interact with the desktop. -displaynamedisplayname
Specifies the display name for the service being set up.
Sets up a program or script to be run as a service (see the DESCRIPTION section).
Displays the service names of all services registered using mksrv,
When used with
-install, it specifies the service name to be used for the service being set up.
When used with
-debugor -remove, it specifies either the service name or the display name of an already existing mksrv-created service. -passwordpassword
Can only be used with
-usernameoption to specify the password for the username account. -quiet
Directs status and error messages to the standard output, which is normally not visible unless redirected.
Removes a mksrv-created service from the roster of services registered with the Service Control Manager.
Removes all services registered using mksrv,
Specifies the username whose account is to be used to run the service. username should also include the domain name when appropriate. You can specify the password associated with this account with the
-passwordoption. When no -passwordoption is specified, mksrv prompts you to enter the associated password. -verbose
Displays a status window even if no error occurs.
The following commands set up the login version of the default shell to run as a service and start it:
mksrv -install -displayname "Shell as LocalSystem" -desktop $SHELL -L service start "Shell as LocalSystem"
A new console window appears that is running using the local system account. The whoami utility can confirm this.
Possible exit status values are:
Windows 8.1. Windows Server 2012 R2. Windows 10. Windows Server 2016. Windows Server 2019. Windows 11. Windows Server 2022.
PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
PTC MKS Toolkit 10.4 Documentation Build 39.