SrvMan - Command Line Options

You can use SrvMan's Command Line interface to perform the following tasks:

Note that when you run SrvMan with command-line arguments from non-console application (for example, from a Run dialog box), it displays the "Press any key to continue..." message and pauses just before exiting. This does not happen, when SrvMan is run from a console application (such as cmd.exe). To override this behavior, use the /pause:no switch.

Creating services

Use the following command line to create services using SrvMan (parameters in brackets are optional):

srvman.exe add <file.exe/file.sys> [service name] [display name] [/type:<service type>] [/start:<start mode>] [/interactive:no] [/overwrite:yes]

Service name is an internal name used by Windows to reference the service. Display name is the name displayed in Windows Services snap-in. By default, both names are generated from the .exe or .sys file name, however, you can override it by specifying names explicitly.

Service type can be one of the following:

Start mode is one of the following:

Win32 services are created as interactive by default. To create a non-interactive service, you should specify the /interactive:no parameter. Normally, if a specified service already exists, SrvMan reports an error and stops. However, if you specify the /overwrite:yes parameter, an existing service will be overwritten instead.

Deleting services

Deleting services using SrvMan command line is quite obvious:

srvman.exe delete <service name>

Note that you need to specify the internal service name (same as used for net start command), not the display name.

Starting/stopping/restarting services

You can control all types of services using SrvMan command line:

srvman.exe start <service name> [/nowait] [/delay:<delay in msec>]
srvman.exe stop <service name> [/nowait] [/delay:<delay in msec>]
srvman.exe restart <service name> [/delay:<delay in msec>]

Normally, SrvMan waits for the service to start. However, if you specify the /nowait parameter, SrvMan will return control immediately after the start/stop request was issued. Note that if you need SrvMan to wait before starting/stopping the service (for example, to switch to real-time log viewer window), you can use the /delay:<delay in msec> parameter.

Testing legacy drivers

You can easily test your legacy driver by using the following command line:

srvman.exe run <driver.sys> [service name] [/copy:yes] [/overwrite:no] [/stopafter:<msec>]

This command creates (or overwrites) a service for a given legacy driver file and starts it. If you have specified the /copy:yes switch, the driver file will be copied to system32\drivers directory. If /overwrite:no is specified, DbgMan will return an error if the service (or the driver file in system32\drivers) already exists. If /after:<msec> is specified, the driver will be stopped msec milliseconds after successful start. You can use this switch to test driver load/unload cycle.