Thursday, September 13, 2007

10 useful Windows command-line commands

This list includes some of the most useful and less known commands that you can run at Windows command prompt.

1. Quickly create an empty file of an arbitrary size

This command is useful if you quickly need a file of a certain size. The command execution is instantaneous (no matter what you put for length), but the file contains only zeros.

fsutil file createnew filename length

2. Create a hardlink

A hardlink is useful when you want to make the same file appear in different folders. Even if you can see it in many places on your drive, the hard drive space is allocated for only one instance.

The file is physically deleted when the last hardlink is removed.

fsutil hardlink create new_filename existing_filename

3. Associate a path with a drive letter

The command is very useful for testing installation kits or running a CD from a folder. It basically creates a new drive letter that points to the indicated folder.

subst [drive1: [drive2:]path]

4. Compares two binary files

This command is useful to check if two files are identical. Checking only the file sizes is not enough since the content may be different.

The fc command, with /b switch, compares the files in binary mode and tells if they are identical or not.

fc /B [drive1:][path1]filename1 [drive2:][path2]filename2

5. Create a list with all files in a given folder

dir *.doc /b > documents.txt

If you want to search also in the subfolders, add the /s switch in the above command line.

dir /s *.doc /b > documents.txt

6. Concatenate two files

This command can be used to concatenate both text and binary files.

copy /b a.txt + b.txt c.txt

7. Check if a server is up

When a machine (internal server, web site, etc) doesn’t respond from the regular application, try to open a command prompt and ping that machine.

Ping can be also used to find the IP behind a web address.


8. Display network configuration and IP addresses

If you are using a DHCP server in your network, then you can use this command to check the IP address leased to your computer.

ipconfig /all

9. Lock workstation

You can lock your workstation by running this command.

rundll32.exe user32.dll,LockWorkStation

10. Shutdown local computer

You can use this command to automate the process of computer shutdown. Some prefer to put it as a link on the desktop.

shutdown -s -f -t 00


Viorel said...

... ce imi place la blogul tau … pai cred ca faptul ca in 2 minute de lectura poti sa afli cam de fiecare data un mic truc care te intereseaza, daca esti un utilizator cel putin mediu de IT. Si atinge zone foarte diverse, de la voip pana la comenzi DOS.

Cred ca ar trebui sa te gandesti un pic cum sa atragi audienta si mai ales cum sa ii faci sa lase feedback. Poate sa incluzi link de feedback in email? Sau un reply la email sa fie adaugat automat ca comentariu?

Anonymous said...

more windows command prompt tips @

Anonymous said...

I wanna to decide some of questions in this area. Could u help me to do it?

Anonymous said...

I dont know what to say. This web site is amazing. Thats not truly a actually substantial statement, but its all I could come up with soon after reading this. You know a great deal about this subject. Much making sure that you produced me wish to understand additional about it. Your web site is my stepping stone, my buddy. Many thanks for that heads up on this theme.

Anonymous said...

hi, new to the site, thanks.