Posts mit dem Label Command line werden angezeigt. Alle Posts anzeigen
Posts mit dem Label Command line werden angezeigt. Alle Posts anzeigen

Mittwoch, 4. Juli 2012

Windows: Create/Delete a service

Create a new service:
sc create SERVICENAME binpath= "<path to executable> -arg1 -arg2"

The excutable is installed as a service. See my other post about building your own service. Please note that there is a space after binpath=.DIf the service needs arguments (which will be passed to the ServiceMain function), you can add them (arg1, arg2 above). Just be sure to surround the executable and the arguments with quotes.

Delete an existing service:
sc delete SERVICENAME

The service will be deleted after the next restart.

Mittwoch, 14. März 2012

Windows: Shutdown via command line

You can shutdown a computer running Windows using the command line. Use the shutdown command to force a shutdown, reboot or hibernate.

Shutdown computer
shutdown /s

Restart computer
shutdown /r

Hibernate computer
shutdown /h

The shutdown command is available since Windows XP. On older versions of Windows use this command:

Restarting the computer
RUNDLL.EXE user.exe,exitwindowsexec

Shut down the computer
RUNDLL32.EXE user,exitwindows