Adding Command-Line Switches To Windows Shortcuts

Use a batch (cmd/bat) file for this purpose. Do not create a shortcut to Excel, but rather create a shortcut to your batch file.  This file will have the necessary logic.  Look at the example image, which is VS.NET command prompt which uses same bat file with parameters.

  1. Find the correct path for Excel, if it is not in path *
  2. use /r
  3. use the correct Excel file name.

* Because the location of Excel may vary from machine to machine, it may be helpful to use start excel "c:\myfile.xls" /r within your batch file.  start excel should initiate Excel regardless of its location.

VS.NET Command Prompt Example


Your shortcut should contain the full path to both the executable and the target file, like this:

"C:\Program Files\Microsoft Office\Office12\EXCEL.EXE" /r "C:\Users\Administrator\Desktop\abc.xlsx"

Note that both EXE and XLS paths are in quotes to avoid problems with spaces in the name.


Target is the field to change. But since a shortcut points to a path two shortcuts to the same file may contain different target depending on how the network drives are mapped. So generally, you can't copy a shortcut over the network and hope it will work, since the target might no longer be valid.