Windows

Start programs with switches in Windows 2000 Pro

If you use command-line switches in conjunction with certain programs in Windows 2000 Professional, you can add those switches to open along with the relevant applications every time you click from a shortcut. Here's how.

Many programs in Windows 2000 Professional support the use of command-line switches that modify the way the program starts or functions. Microsoft Word, for example, supports an /M switch that prevents autoexec macros from executing at program startup. Most of the console commands (XCOPY, DIR, etc.) also support several switches. It's easy to add switches to control the way an application starts.

If you're starting the application from a shortcut, just modify the shortcut to include the necessary switch or parameter.

  1. Right-click the shortcut on the desktop, in the folder, or even in the Start menu, and choose Properties.
  2. Look in the Target text, which contains the application-executable path enclosed in quotes. To the right outside the quotes, add the switches or program parameters you want to use. Make sure to add them outside the quotes or you'll get an error message.
  3. Close the Properties sheet, and then launch the application from the shortcut to test the switch.

Miss a column?

Check out the Windows 2000 Professional archive, and catch up on all the W2K Pro columns.

Want more Win2K tips and tricks? Automatically sign up for our free Windows 2000 Professional newsletter, delivered each Tuesday!

16 comments
tedatwork
tedatwork

Wow, some programs have command line switches??? Next I guess your gonna tell me that there are some really usefule command line tools, but not bother to list any or their uses...

deepsand
deepsand

This is a Win 2K feature? I seem to recall this being around since Win 95.

Day-by-Day
Day-by-Day

Each application may have its own set of switches to control initial behavior. The fact that applications my have switches used to be common knowledge, before the days that the GUI became the only way to communicate with an application. Unfortunately, it is not unusual for the command line switches to only be documented via the command line help and not even be mentioned in the GUI help. While /? has become a defacto standard to trigger the command line help for Microsoft applications, it is a standard that is often ignored by many developers. Use the following steps (which should have been included in the article) to discover if command line switches are available for an application. An installation process typically places a shortcut to the application image in one or more of the following locations: Desktop, Quick Launch, and Programs folder. Find the shortcut for the application, then right click the shortcut and select Properties. On the Shortcut tab you will find a Target text box which specifies the location of the executable. Select the Target text box contents and copy it. Paste the contents in a Command Prompt window. Now the trick is to discover if the developer has implemented command line switches. I'm going to use the System Information utility (Start|Programs|Accessories|System Tools|System Information) to illustrate this process. In this case, the line pasted in the Command Prompt window should look something like c:\> "C:\Program Files\Common Files\Microsoft Shared\MSInfo\msinfo32.exe" Just hitting the enter key should execute the command line and the System Information window will appear. Cancel the System Information window and select the command line window. Recall the command line (e.g. select the Command Prompt window and hit the up arrow key) and add " ?" to the command. The revised command should then look like c:\> "C:\Program Files\Common Files\Microsoft Shared\MSInfo\msinfo32.exe" ? Hitting the Enter key again simply creates another System Information window, so "?" is not a switch. So cancel the System Information window, select the command line window, and try again, but this time use " /?" c:\> "C:\Program Files\Common Files\Microsoft Shared\MSInfo\msinfo32.exe" /? This time a pop-up listing the command line options for the application appears. Look through the options, try the various switches, and see if there are any that are valuable for you. If you decide that the History view (/pch) is extremely helpful and want to be able to startup System Information in this mode, the safest way is to create a new shortcut to the application, and add /pch to the shortcut target property as previously described. Now, whenever this shortcut is used, System Information will start in the history mode. When searching for command line switches, the variations to try are (cmd.exe is used as a place holder for the command you're testing): c:\> cmd.exe c:\> cmd.exe /? c:\> cmd.exe ? c:\> cmd.exe -? c:\> cmd.exe /help c:\> cmd.exe help c:\> cmd.exe -help At times it can be enlighting to create a temporary file and use it as a test argument: c:\> echo.> %TEMP%\cmd.txt c:\> cmd.exe %TEMP%\cmd.txt Doing this with the System Information triggers a pop-up with the message This is not a file type System Information can open. So we know that System Information will accept a filename argument (not new information in this case because the command line help display told us that filename is a valid argument). But this test is worth trying if you're not able to trigger a command line help display or if the help display doesn't mention a filename argument.

inertman
inertman

that if you type /? after the exe file you get the switches listed. and after trying it again just now w/ cmd.exe /? i found a very long list of them. it's my understanding that this is a common knowledge, or at least used to be. but since not all programs have switches, this obviously doesn't always provide info. however, i found similar instancesin vista while trying toadjust the boot-up sequence. however, i agree that this 'article' is terribly lacking.

maagero
maagero

I wrote a reply to another member who wrote about Terminal Services and it's ease of installation and usage, but he did not realize that TermSvcs is not a simple "Windows module" to install. This article does the same thing. In this subject, one cannot explain all switches, but generally the executable followed by "/?" will provide the help on the switches available for that command. For instance, in Win-XP "c:\windows\system32\shutdown.exe /?" will provide the following: Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy] No args Display this message (same as -?) -i Display GUI interface, must be the first option -l Log off (cannot be used with -m option) -s Shutdown the computer -r Shutdown and restart the computer -a Abort a system shutdown -m \\computername Remote computer to shutdown/restart/abort -t xx Set timeout for shutdown to xx seconds -c "comment" Shutdown comment (maximum of 127 characters) -f Forces running applications to close without warning -d [u][p]:xx:yy The reason code for the shutdown u is the user code p is a planned shutdown code xx is the major reason code (positive integer less than 256) yy is the minor reason code (positive integer less than 65536) !!! NOTE: I did find out that the shutdown switches like "-s" the syntax is "/s" or "/r". For instance, the Task Scheduler, "c:\windows\system32\shutdown.exe /r" can refresh an XP-PC or W2K3 server once a month or "c:\windows\system32\shutdown.exe /s" can shutdown an XP-PC that is left on by user at 11:00pm daily. This will ensure your PC's are off at night. Although, be careful of open apps. I have over 20 years experience in the computer/electronics field and I am always learning something new. Please, if you're going to write a how-to article put some meat into it. Thanks.

robwaybro
robwaybro

That this column would actually have the switches that could be used in various applications. The ability to use switches is rather well known, but knowing what the switches are would have made a much better article.

deepsand
deepsand

If it were possible, I'd have given it a Zero; since the scale is 1 to 5, give it a 1.

ali40961
ali40961

It is a good refresher for the pros and a nice intro for those of us less fortunate (meaning NOT a pro). DITTO to all the comments about these articles being less meat and more potatoes. Seems lots of PROs forget what it is like to be NOT a pro. Several of these "How To" articles dealing with the command console leave out the FIRST step, how to get to the command console.

mikec
mikec

I subscribe to TechRepublic to get information. I have noted a disturbing trend of fluff pieces that convey no useful information. This was one of them. As another poster said, "Is there anyone here who doesn't know CL switches exist?" This article was totally useless, and a waste of time I could have spent learning something or servicing a customer. Let's try and return to the idea that TechRepublic is a place to come for information, and leave the fluff for the Sunday supplements!!!

KTC
KTC

I have to agree with robwaybro. I also tuned into this article to check out some switches I might not know of in a 2000 system. Are there really folks who tune into TR articles that don't in general know about switches?

deepsand
deepsand

If the point of the article was to be a "refresher," then it should have be directed to a wider audience. If you check other Articles by this author, you will find that, while the Titles are long on promise, the content is short on substance. And, that the matters touched upon are [b]not[/b] Win 2K centric at all.

ichinutz
ichinutz

This is fairly typical of Jim Boyce's articles over the last couple of years, it is just outline with no filling. Whoever is ultimately responsible for this appalling attempt at technical journalism, they need their butt kicking!

tyler.poland
tyler.poland

This article would have been immensely more valuable if it had given some examples of valuable switches.

jhlamothe
jhlamothe

Obvious how-to, not a secret way to shorten launch.

rkuhn040172
rkuhn040172

MS Word: http://support.microsoft.com/default.aspx?scid=kb;EN-US;210565 MS Excel: Prevent display of the Excel startup screen and a new blank workbook /e or /embedded Create a new workbook that contains a single macro sheet /m Force Excel to re-register itself /o Specify the working folder as the active working folder instead of the default working folder /p workbook path Open a specific workbook as read-only /r workbook path\file name Specify Office Safe Mode /s, /safe, or /safemode Open and close Excel to rewrite all registry keys and reassociate Excel with all Excel files, such as workbooks and /regserver Open and close Excel to unregister Excel /unregserver I agree the article was seriously lacking, but a quick Google search reveals the rest.

it_admin
it_admin

Does somebody know where to get a usefull list of switches?

Editor's Picks