# Remove a Windows Service

## Remove a Windows Service

Category : How-to

Get Social!

You can easily remove a Windows service from the Windows registry using a simple command prompt command called SC.

SC is the command line utility which interacts with the Windows Service Controller and can be used to manage services on either a remote or local Windows machine.

You will need to find the name of the service you would like to remove before you can issue the SC command to remove it. You can either use the Windows Service console or the sc query command to find the name of a service.

Click the Start menu and type in Services and click the Windows Services console in the list. Find your service by name and double click it to see the Properties window. The service name can be seen at the top of the form. The below example shows the Skype Updater service.

To use the sc query command to find your service name, open up a command prompt and type the below command.

sc query

Find the SERVICE_NAME attribute of your required service.

Once you have the service name, you will need to stop the service before you can delete it. Issue the sc stop command followed by the service name. The below example show how to stop the SkypeUpdate service.

sc stop SkypeUpdate

Finally, you can issue the sc delete command to remove the service.

sc remove SkypeUpdate

## doskey in Windows is just like alias in Linux

Category : How-to

Get Social!

doskey on Windows is very similar to alias on Linux, it allows you to set a term which will call a command and allow you to specify default arguments. You can specify that the command showdirs could call the command dir to list the content of a folder.

You may have guessed, the above use of doskey is unlikely and has no real benefit. A better use of the command would be to turn some of the windows commands into their Linux counterparts – such as ls into dir.

Run the below command in a command prompt to alias ls to run the command dir. The $* on the end are required so that any additional arguments are also passed to the dir command. doskey ls=dir$*

The problem with this is that all of your alias commands will be lost when you close the cmd session. To make them persist we need to create a batch file and add the entry to the windows registry.

Create a new folder in the windows directory called bin and create a new batch file inside it.

C:\>mkdir c:\windows\bin
C:\>notepad.exe c:\windows\bin\doskey.bat

@echo off
doskey ls=dir $* doskey mv=move$*
doskey cp=copy $* doskey cat=type$*

Next, open up regedit.exe and add an entry to the batch file to make the doskey commands permanent for each cmd session.

HKEY_CURRENT_USER\Software\Microsoft\Command Processor

Add a new String Value called AutoRun and set the absolute path in the value of c:\windows\bin\doskey.bat.

The doskey.bat file will now be executed before opening a new cmd session which will set all of your alias ready for you to use.

## Map a Network Drive from the Windows Command Line

Category : How-to

Get Social!

The windows command line can be very useful to quickly perform repetitive tasks.

It is easy to write batch scripts which combine actions and can be easily triggered from the command line.

Mapping a network drive in Windows in a common task and can be done from the command line.  The syntax is:

net use [drive letter]: /persistent:[yes|no] "\\path\to\share"

The persistent command will make the mapped drive persist over reboots.

The below example maps drive Z to a server called fileserver.jamescoyle.net and the share homes.

net use z: /persistent:yes "\\fileserver.jamescoyle.net\homes"

## Restart Windows from the command line

Category : How-to

Get Social!

Sometimes you may want to restart windows without clicking the Start menu. In some cases, such as in a remote desktop session, the option to restart Windows is missing completely from the Start menu.

You can restart Windows XP/ Windows Server 2003 or newer, using the Windows command line or a shortcut.

shutdown -r -t 10

-r: is the argument to request a restart, rather than a complete shutdown.
-t n: is used to specify a delay, before the restart command will take effect. The default is 60 seconds. ‘n’ represents the time in seconds.

To name a few just a few, you can run this command from the Run dialogue, from a CMD, or from a shorcut.