• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
(Batch) Useful batch commands
#1
Useful batch commands


STEP ONE:

In this tutorial you will be learning how to use the following commands:

cd
copy
del
start


STEP TWO:

cd

The cd command is used to navigate to a directory.

For example, if you wanted to navigate to be the desktop the command would be:

cd "%userprofile\Desktop%"


[Image: 5djy48.jpg]

This command is one of the more useful ones to know because it needs to be used in conjunction with the other commands.

STEP THREE:

copy

The copy command allows you to copy a file from one directory to another.

Before you are able to use the copy command, you need to know how to use "cd", this is because you need to be in the directory from which you want to copy the file from.

When using the copy command you need to use it in the following way:

copy "filename" "chosen path to copy the file to"

Where it says "filename", replace it with the name of the file you want to copy and where it says "chosen path to copy the file to", replace that with the directory of where you want the file to be copied to.

For example, if you've got a file called copy.txt that you want to copy to the desktop the code would be:

copy copy.txt "%userprofile%\Desktop"

[Image: i2k5eq.jpg]


STEP FOUR:

del

This del command is used to delete things, it can be used to delete single files or an entire hard drive.

Similar to the copy command, for the "del" command to work you need to cd into the directory where the file is.

When using the del command it takes the following structure:

del "filename"

Where it says "filename" replace that with the name of the file you want to delete.

For example, if you wanted to delete the file delete me.txt then the command would be:

del "delete me.txt"

[Image: 6puqew.jpg]


STEP FIVE:

start

The start command is used to start or open something, it can be a file or a program.

Just like the copy and del commands, for the start command to work you'll need to select a directory using the "cd" command.

Once the directory has been selected you type:

start "filename.extension"

Where it says "filename" replace that with the file you want to start / open - and where it says ".extension" replace that with the file type, eg .exe or .txt

For example, to start Internet Explorer you type:

start iexplore.exe


[Image: 2uqhqaf.jpg]


I hope this has helped.
  Reply


Messages In This Thread
(Batch) Useful batch commands - by Mark - 22-05-2010, 10:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to make a menu in batch (And start processes) Mark 3 9,856 13-07-2010, 02:34 AM
Last Post: Jamez247
  (Batch) How to shutdown a computer using a batch file Mark 0 6,446 22-05-2010, 10:49 PM
Last Post: Mark
  (Batch) Autostarting programs on login Mark 0 5,051 22-05-2010, 10:44 PM
Last Post: Mark
  (Batch) Hello world - Your first Batch program Mark 0 6,527 22-05-2010, 10:35 PM
Last Post: Mark

Forum Jump: