Thursday, October 27, 2011

Batch files - useful commands

We all need from time to time to create batch files to make our work easier.
Here are some useful commands:

1. First to create a batch file open Notepad.exe and save the file as 'anything.bat'. And you have a batch file that you can edit.

2. Copy files XCOPY command:

XCOPY [source] [destination] [(optional) parameter]

Ex: XCOPY C:\test\text.txt C:\newtest\ /Y
- this will copy the text.txt file from C:\tets to C:\newtest and override it if it already exists, supressing the confirmation.

3. Stop/Start Windows Services - NET STOP / NET START commands:
NET STOP [windows service]

EX: net stop "World Wide Web Publishing Service"
net start "World Wide Web Publishing Service"

4. Rename files - REN command
REN [drive:][path]old_filename new_filename

Ex: REN C:\test\text.txt newtext.txt

5. Import .reg fiel in Registry - REGEDIT.EXE command
REGEDIT.EXE [ /parameters ] importfile.REG

Ex: REGEDIT.exe /S "C:\test\Add registry key.reg"
- this will silently import the 'Add registry key.reg' file into Registry

6. Reset IIS - IISRESET command
iisreset

To be continued...

Useful links:
http://commandwindows.com/windows7-commands.htm
http://support.microsoft.com/kb/240268
http://aumha.org/a/batches.php
http://ss64.com/nt/ren.html
http://www.robvanderwoude.com/regedit.php

No comments:

Post a Comment