Windows Basics

Command line arguments are just values that are passed to an executable file when it is run. Also known as "command line switches" or "command line options," command line arguments are usually used to set program options, or to pass along the location of a file that the program should load.

They're called command line arguments because they are generally used when launching a program from a command line (also known as the "DOS prompt" in Windows). In fact, command line arguments go way back, to the days before computers had fancy graphical user interfaces, when typing stuff into a command line was the only way to run a program.

When a program is running, it can access any command line arguments that were passed to it and make decisions about them. Every executable accepts different arguments and interprets them in different ways.

For example, entering C:\abc.exe /W /F on a command line would run a program called abc.exe and pass two command line arguments to it: /W and /F. The abc.exe program would see those arguments and handle them internally.

Note: Not all executables use command line arguments, and the list of meaningful command line arguments is specific to each program. /W might mean "wait for return" in one program, but it could mean "enable wacky walk animation" in anotheror it might not even be recognized at all.

Tip: Many programs will display a list of the command line arguments they support if you run them with the /? option.

You can test command line arguments by running an executable from the "Command Prompt" in Windows NT, 2000, XP, Vista or later, or from the "DOS prompt" in older versions of Windows. You can also use command line arguments in program shortcuts, or when running an application by using Start -> Run.

For example, to run notepad on a typical Windows XP system, you can go to Start > Run and type in:

C:\Windows\notepad.exe

This will start notepad with a blank document. In this case, there are no command line arguments being passed to the program (notepad).

But, if you go to Start > Run and also type in the path to an existing text file:

C:\Windows\notepad.exe C:\Docs\Info.txt

...then notepad will open up with that C:\Docs\Info.txt document loaded into it. In this case, "C:\Docs\Info.txt" is a command line argument being passed to notepad.exe. Notepad detects the argument, sees that it's the path to a text file, and loads that file automatically (which is what notepad does when you pass it the path to an existing text file).

Tip: Note that command line arguments are separated by spaces. If you need to pass a command line argument that contains one or more spaces, you can surround the argument with quotes. The quotes will make the spaces part of the argument. For example:

abc.exe D:\open this file.txt


...would be seen as 3 arguments: "D:\open", "this" and "file.txt". To pass the path as a single argument, you need to surround it with quotes, like this:

abc.exe "D:\open this file.txt"

Next: The Windows Clipboard

Сайт управляется системой uCoz