ProblemYou want to customize the way you open an application. For example, you might want Microsoft Word to run a specific macro when it first starts. SolutionUsing a graphical user interfaceWhen you use a shortcut to launch a program, as outlined in Recipe Recipe 4.5, you can use parameters and switches that let you customize the way it runs. These switches and parameters are usually specific to each individual program, although some work on many or all programs. For example, you can launch any Microsoft Office application and have it automatically open a specific document by using the right syntax in the Target box. For example, if you wanted to launch Microsoft Word and have it automatically open a file called Chapter 9.doc in the C:\Power Tools Book directory, you'd put this in the Target box (make sure to include the quotes): "C:\Program Files\Microsoft Office\Office11\WINWORD.EXE" "c:\Power Tools Book\Chapter 9.doc" In addition to launching individual files, you can use a variety of switches. For example, if you wanted to open Word without opening a document and not have previously opened documents show up in the Word File menu, you'd use the switch /n in the Target box: "C:\Program Files\Microsoft Office\Office10\WINWORD.EXE" /n And you can combine switches with opening individual files. So if you wanted to run Word and have it open a file called Chapter 9.doc in the C:\Power Tools Book directory, and have Word run a specific macro but not run any Autoexec macros, you'd use this syntax: "C:\Program Files\Microsoft Office\Office11\WINWORD.EXE" /m "c:\Power Tools Book\Chapter 9.doc" Tables 4-2 through 4-5 list switches for Microsoft applications Word, Excel, PowerPoint and Outlook.
Using a command-line interfaceYou can use the same syntax, switches, and parameters at the command line as you can in the Target box when you create a shortcut. So you can launch applications using those parameters and switches straight from the command line.
To launch a program at the command line, type in its full path and filename, then press Enter, like this. (Note that you won't have to type in the path, if the file can be found in your PATH.) C:\Program Files\Microsoft Office\Office11\WINWORD.EXE Add switches and parameters as outlined earlier in this recipe. For example: C:\Program Files\Microsoft Office\Office11\WINWORD.EXE /n DiscussionThe true power of using switches and parameters for launching programs comes into play when you use them with shortcuts. If you have a particular customized way that you generally like to launch an application, create a shortcut for it with the right switches and parameter, and normally run it that way. But then, when you vary from your normal way of launching it if you want to launch a specific file, for example it'll be easier to use the command line. Also, consider creating multiple shortcuts for each of your applications, so that you can launch different customized versions. Remember when you use the command line that the command you type in doesn't include quotes around it, but when you use the Target box for creating shortcuts, you need to include the quotes. (On the command line, though, if you're using a path with any spaces, you need to include quotes.) Finally, keep in mind that many applications, not just Microsoft Office applications, include switches and parameters you can use to launch them, so check your documentation or the web site of the software make to find them. See AlsoRecipe 4.5 for help in creating keyboard shortcuts; MS KB 130510, "Command-Line Switches for Windows Explorer," and MS KB 296192, "OL2002: Additional Command-Line Switches" |