A collection of

Command Line Switches

and arguments to control some program executables

On this page I will collect command line switches for some program executables.
This will make it easier to create reliable "quick-and-dirty" batch files to perform common tasks like printing, file conversion, etcetera without the need to dig into the program's COM object details.

Most programs open a file if its full path is specified on the command line without any switches.
Most files' "Open", "Print" and "PrintTo" commands can be found in the registry under HKEY_CLASSES_ROOT, or by examining file associations, the others may require some web searching, or even reading software manuals. 

 

Command line switches for:

Microsoft Access

Open a Microsoft Access database:

    msaccess.exe Database

Open an Access database for exclusive access:

    msaccess.exe Database /excl

Open an Access database for read-only access:

    msaccess.exe Database /ro

Compact and repair an Access database:

    msaccess.exe OriginalDatabase /compact [ CompactedDatabase ]

If no CompactedDatabase is specified, the OriginalDatabase will be overwritten.

Convert a database from a previous Access version to the current version:

    msaccess.exe OldDatabase /convert NewDatabase

Sources with more details:

Not tested

 

Back to the top of this page . . .

Adobe Reader

Get Adobe Reader

Open a PDF file:

    AcroRd32.exe PdfFile

Open a PDF file in a new instance of Adobe Reader:

    AcroRd32.exe /N PdfFile

Open a PDF file at page 7:

    AcroRd32.exe /A "page=7=OpenActions" PdfFile

Open a PDF file with navigation pane active, zoom out to 50%, and search for and highlight the word "batch":

    AcroRd32.exe /A "zoom=50&navpanes=1=OpenActions&search=batch" PdfFile

Print a PDF file with dialog:

    AcroRd32.exe /P PdfFile

Print a PDF file silently:

    AcroRd32.exe /N /T PdfFile PrinterName [ PrinterDriver [ PrinterPort ] ]

The last command will open a new Adobe Reader window, print the PDF file and then terminate its window unless that window happens to be the only Adobe Reader window left: at least one Adobe Reader window will be left open.

Sources with more details:

Tested with Adobe Reader 8.1.2 on Microsoft Windows XP Professional SP2 (5.1.2600)

 

Back to the top of this page . . .

AVG Antivirus

Scan and clean a file (scan inside archives and alternate data streams too):

    avgscanx.exe /scan=file /ext=* /arc /ads /clean

Thoroughly scan and clean the entire computer:

    avgscanx.exe /comp /ext=* /reg /boot /proc /macrow /pup /arc /ads /clean

Run a high priority quick test on the computer, take no action, and report the results including password protected archives:

    avgscanx.exe /comp /qt /priority=high /pwdw /report=d:\avgreport.txt

Scan all files in directory d:\datadir, move infected files to the virus vault, report the results:

    avgscanx.exe /scan=d:\datadir /ext=* /trash /report=d:\avgreport.txt

Update virus definitions:

    avgupd.exe
Notes: (1) Use avgscana.exe for Intel 64 bits processors.
  (2) Return codes:
0: everything is o.k.
1: user cancelled/interrupted test
2: any error during the test - cannot open file etc.
3: change identified
4: suspicion detected by heuristic analysis
5: virus found by heuristic analysis
6: specific virus detected
7: active virus in memory detected
8: AVG corrupted
9: double extension
10: archive contains password protected files

Sources with more details:

Tested with AVG Antivirus version 8.0.145 (engine 8.0.0) on Microsoft Windows XP Professional SP3 (5.1.2600)

 

Back to the top of this page . . .

CDBurnerXP

Get CDBurnerXP

Open a CDBurnerXP compilation file:

    cdbxp.exe /od CdbxpCompilationFile

List all CD/DVD writers:

    cdbxpcmd.exe --list-drives

Eject the disk in the first CD/DVD writer (device 0):

    cdbxpcmd.exe --eject [ -device:0 ]

Load the disk in the first CD/DVD writer (device 0):

    cdbxpcmd.exe --load [ -device:0 ]

Erase the disk in the first CD/DVD writer (device 0):

    cdbxpcmd.exe --erase [ -device:0 ]

Unfortunately, so far, I haven't been able to burn a CD with cdbxpcmd.exe yet.

Source with more details:

Tested with CDBurnerXP Pro 4.1.1.660 on Microsoft Windows XP Professional SP2 (5.1.2600)

 

Back to the top of this page . . .

Digital Photo Professional

Open the d:\photos folder in DPP, and display directory tree:

    DPPViewer.exe /path d:\photos /tree:on

Open the last used folder in DPP, do not display directory tree:

    DPPViewer.exe /tree:off

Tested with Canon's Digital Photo Professional 3.7.2.0 on Microsoft Windows XP Professional SP3 (5.1.2600) and Microsoft Windows 7 Ultimate RC (6.1.7100)

 

Back to the top of this page . . .

Excel

Open an Excel spreadsheet:

    excel.exe ExcelSpreadsheet

Open an Excel spreadsheet in read-only mode:

    excel.exe /r ExcelSpreadsheet

Open an Excel spreadsheet in safe mode:

    excel.exe /s ExcelSpreadsheet

or:

    excel.exe /safemode ExcelSpreadsheet

Sources with more details:

Not tested

 

Back to the top of this page . . .

Mozilla Firefox

Get Firefox

Open an url in the browser:

    firefox.exe -url www.mozilla.com

or:

    firefox.exe www.mozilla.com

Open Firefox in safe mode (all add-ons disabled for this session only):

    firefox.exe -safe-mode www.mozilla.com
Note: Won't work if another instance of Firefox is running.

Open an url in a new tab in the browser:

    firefox.exe -new-tab www.mozilla.com

Open an url in a new browser window:

    firefox.exe -new-window www.mozilla.com

Search using Firefox' default search engine:

    firefox.exe -search "batch files"

Make Firefox the default browser:

    firefox.exe -setDefaultBrowser

Sources with more details:

Note: You may want to experiment with these switches. On some systems, besides opening a specified URL, I couldn't get any of these switches working. This may have be caused by one or more add-ons, or it may not...

Tested with Mozilla Firefox 3.0.4 on Microsoft Windows XP Professional SP3 (5.1.2600)

 

Back to the top of this page . . .

Foxit Reader

Open a PDF file:

    "Foxit Reader.exe" PdfFile

Open a PDF file at page 7:

    "Foxit Reader.exe" PdfFile -n 7

Make Foxit Reader the default PDF reader:

    "Foxit Reader.exe" -Register

Print a PDF file silently to the default printer:

    "Foxit Reader.exe" /p PdfFile

Print a PDF file silently to an alternative printer:

    "Foxit Reader.exe" /t PdfFile PrinterName

The next 2 undocumented switches were discovered by Wolfgang Eitel with the aid of SysInternals' ProcessMonitor:

Force Internet Explorer and Firefox to open PDF files inside the browser window:

    "Foxit Reader.exe" -displayinbrowser

Force Internet Explorer and Firefox to open PDF files outside the browser window:

    "Foxit Reader.exe" -undisplayinbrowser
Notes: (1) The /p and /t switches are case sensitive, the -n switch is not.
  (2) Though the Foxit Reader 3.0 Manual suggests otherwise, in version 3.0 the /p and /t switches must be placed at the beginning of the command line, before the file name.

Source with more details:

Tested with Foxit Reader 2.3 Build 2923 on Microsoft Windows XP Professional SP2 (5.1.2600), Foxit Reader 3.0 Build 1817 on Microsoft Windows XP Professional SP3 (5.1.2600) and Microsoft Windows 7 RC (64-bits) (6.1.7100), and Foxit Reader 4.3.1.0218 on Microsoft Windows 7 SP1 (64-bits) (6.1.7601)

 

Back to the top of this page . . .

Internet Explorer

Get Internet Explorer

Open an URL in Internet Explorer:

    iexplore.exe url

Open Internet Explorer without add-ons (IE 7 and later versions only):

    iexplore.exe -extoff [ url ]

Open Internet Explorer in Windows Explorer mode (IE 7 and earlier versions only):

    iexplore.exe -e Folder

It is not possible to start a Windows Explorer window with alternate credentials.
That is where Internet Explorer's "Explorer mode" comes to the rescue:
use RUNAS and IE's -E switch to start an Explorer look-alike window with alternate credentials.
Folder can be in "drive:\path" or UNC format.

As of IE 7 this workaround may no longer work, as the -e switch became obsolete (though it still does work on my Windows 7 (64-bits) system).
You may want to try this "direct" approach first:

    explorer.exe /separate[,Folder]

This works in Windows 7 (64-bits), not sure about other Windows versions though.

Open Internet Explorer in kiosk mode:

    iexplore.exe -k [ url ]

Source with more details:

Tested with Internet Explorer 5..7 on Microsoft Windows 2000 & XP Professional, and with Internet Explorer 8 on Microsoft Windows 7 RC (64-bits)

 

Back to the top of this page . . .

IrfanView

Open a graphics file:

    i_view32.exe GraphicsFile

Print a graphics file to the default printer:

    i_view32.exe GraphicsFile /print

Print a graphics file to any printer:

    i_view32.exe GraphicsFile /print="PrinterName"

Convert a JPG file to TIFF:

    i_view32.exe FileName.jpg /convert=FileName.tif

Convert a JPG file to TIFF, and resize it to 800x600 (but keep the aspect ration):

    i_view32.exe FileName.jpg /resize=(800,600) /aspectratio /resample /convert=FileName.tif

Scan and print a page:

    i_view32.exe /scanhidden /print

Play selected JPG files as a slideshow:

    i_view32.exe /slideshow=drive\path\img*.jpg /closeslideshow

Capture the screen and save it as C:\TEST.JPG:

    i_view32.exe /capture=0 /convert=c:\test.jpg
Note: All switches must be in lower case.

Sources with more details:

Tested with IrfanView 4.10 on Microsoft Windows XP Professional SP2 (5.1.2600)

 

Back to the top of this page . . .

MagicISO

Get MagicISO

MagicISO.exe is the program's GUI executable, but in the same directory where MagicISO.exe is installed, MagicISO's command line tool miso.exe can be found.

List all available CD/DVD writers with their ID number and drive letter:

    miso.exe NULL -cd

Quick erase the disk in the CD/DVD writer with ID number 1:

    miso.exe NULL -e 1

Create and burn a new ISO file to the CD/DVD writer with ID number 2:

    miso.exe ISOFileName.iso -c NewFolder -f NewFolder -a *.* -l3 -l VolumeLabel -be 2
Notes: The -c switch creates a folder NewFolder in the root directory of the ISO image, the -f switch makes this new folder the working directory.
  -a *.* adds all files from the current directory, including subdirectories, to the ISO image's working directory.
  -be 2 tells the program to quick erase the disk in the CD/DVD writer with ID number 2 if it isn't blank, and then burn the ISO image to the disk.
  If ISOFileName.iso already existed, the files and folder(s) will be added to the existing ISO image.
  Use -l1 instead of -l3 if you want to restrict file and folder names in the ISO image to their short "8.3 notation".

Delete files from an existing ISO image:

    miso.exe ISOFileName.iso -f Folder -d FileSpec

Convert an existing ISO image to Nero's NRG format:

    miso.exe NeroFileName.nrg -conv nrg ISOFileName.iso

Sources with more details:

Tested with MagicISO 3.1.113 on Microsoft Windows XP Professional SP2 (5.1.2600)

 

Back to the top of this page . . .

Nero Burning ROM

Get Nero 9

nero.exe is Nero Burning ROM's GUI executable, but when Nero is installed, the command line tool NeroCmd.exe will be installed too.
For Nero 8, NeroCmd.exe's location can be found in the registry value HKEY_LOCAL_MACHINE\SOFTWARE\Nero\Shared\Lib

Open dialogs

Open Nero Burning ROM in the "Create Bootable CD" dialog:

    nero.exe /New:BootDisc /Media:CD

Open Nero Burning ROM in the "Burn Image to CD" dialog:

    nero.exe NeroImageFile /Dialog:BurnImage /Media:CD

Open Nero Burning ROM in the "CD Copy" dialog:

    nero.exe /Dialog:DiscCopy /Media:CD

Open Nero Burning ROM in the "DVD Copy" dialog:

    nero.exe /Dialog:DiscCopy /Media:DVD
Note: A /W switch may be required when using Nero Express.

Unattended

List available CD/DVD writers:

    NeroCmd.exe --listdrives

List drive properties for CD/DVD writer E:

    NeroCmd.exe --driveinfo --drivename E

List disk properties for CD/DVD in drive E:

    NeroCmd.exe --discinfo --drivename E

Eject the disk from drive E:

    NeroCmd.exe --eject --drivename E

Load the disk in drive E:

    NeroCmd.exe --load --drivename E

Quick erase disk in CD/DVD writer E:

    NeroCmd.exe --erase --drivename E --real

Full erase disk in CD/DVD writer E:

    NeroCmd.exe --erase --entire --drivename E --real

Write a Nero image to CD/DVD writer E:

    NeroCmd.exe --write --drivename E --image NeroImageFile --force_erase_disc --real

Quick erase a rewritable disk in E: and then write "drive\path\*.*" to it at 4x speed:

    NeroCmd.exe --write --drivename E --speed 4 --iso VolumeLabel
				--create_iso_fs "drive\path\*.*" --force_erase_disc --real
Note: The 2 lines in the command above should be typed as a single line.

Sources with more details:

Most commands were tested with NeroCmd version 1.9.0.1/Nero API version 6.6.0.19 on Microsoft Windows XP Professional SP2 (5.1.2600), the CD Copy and DVD Copy commands were tested with Nero version 8.0.0.0/Nero API version 8.3.2.1 on Windows XP Professional SP3 (5.1.2600)

 

Back to the top of this page . . .

Notepad

Open a text file in Notepad:

    notepad.exe TextFileName

Force Notepad to open a text file as ASCII text:

    notepad.exe /A TextFileName

Print a text file with Notepad (default printer):

    notepad.exe /P TextFileName

Tested in Microsoft Windows XP Professional SP2 (5.1.2600)

 

Back to the top of this page . . .

OpenOffice

Get OpenOffice

Open a file in OpenOffice, don't show the splash screen:

    soffice.exe -nologo OpenOfficeFile

Open a new text document in OpenOffice:

    soffice.exe -writer
Note: Use -base for databases, -calc for spreadsheets, -draw for drawings, -impress for presentations, -math for formulas, -web for HTML pages, and -writer for text documents.

Open a document in view (read-only) mode:

    soffice.exe -view OpenOfficeFile

Start a presentation:

    soffice.exe -show OpenOfficeImpressFile

Print an OpenOffice file silently to any printer:

    soffice.exe -pt "PrinterName" OpenOfficeFile

Print multiple OpenOffice text files silently to any printer:

    soffice.exe -pt "PrinterName" *.odt

Sources:

Tested with OpenOffice.org 2.4.0 on Microsoft Windows XP Professional SP3 (5.1.2600)

 

Back to the top of this page . . .

PowerPoint

Open a PowerPoint file in Edit mode:

    powerpnt.exe PowerPointFile

Open a PowerPoint file in Slideshow mode:

    powerpnt.exe /S PowerPointFile

Open a print dialog:

    powerpnt.exe /P PowerPointFile

Silently print a PowerPoint file to any printer:

    powerpnt.exe /PT "PrinterName" "" "" "PowerPointFile"

Open a PowerPoint file and run an embedded macro:

    powerpnt.exe /M PowerPointFile "MacroName"

Sources with more details:

Not tested

 

Back to the top of this page . . .

PowerPoint Viewer

Get PowerPoint Viewer 2007

Open a PowerPoint file in Slideshow mode:

    pptview.exe PowerPointFile

Open a print dialog (without "splash screen"):

    pptview.exe /S /P PowerPointFile

Sources with more details:

Tested with PowerPoint Viewer 2007 (12.0.6211) on Microsoft Windows XP Professional SP2 (5.1.2600)

 

Back to the top of this page . . .

Corel Presentations

Open an existing slideshow or drawing in Presentations:

    Prwin12.exe PresentationsDrawingOrSlideshow

Open a copy of an existing slideshow or drawing as a new file:

    Prwin12.exe /s PresentationsDrawingOrSlideshow

Open Presentations with a new drawing:

    Prwin12.exe /bsd

Open Presentations with a new slideshow:

    Prwin12.exe /bss

Source:

Tested with Corel WordPerfect Presentations 12.0.0.602 on Microsoft Windows XP Professional SP2 (5.1.2600)

 

Back to the top of this page . . .

Corel Quattro Pro

Open an existing spreadsheet in Quattro Pro, without showing the "splash screen":

    qpw.exe Spreadsheet /n

Open a password protected spreadsheet without the password dialog:

    qpw.exe Spreadsheet /spassword

Repair a damaged spreadsheet:

    qpw.exe Spreadsheet /r1
Note: This will remove all objects from Spreadsheet.
If that doesn't fix the file, use the /r2 switch, which will also remove all formulas.

Source:

Except for the repair options, tested with Corel Quattro Pro 12.0.0.602 on Microsoft Windows XP Professional SP3 (5.1.2600); /n switch also tested with Corel Quattro Pro X4 on Microsoft Windows XP Professional SP3 (5.1.2600) and Microsoft Windows 7 Ultimate RC (6.1.7100)

 

Back to the top of this page . . .

Microsoft RAW Image Viewer

Get Microsoft RAW Image Viewer

Open a RAW image in the viewer:

    RAWSupport.exe RawImageFile

Open the print wizard:

    RAWSupport.exe /print RawImageFile

Open a RAW image in the associated editor, if configured:

    RAWSupport.exe /edit RawImageFile
Note: A RAW image editor is not part of Microsoft's RAW Image Viewer package.

Open the RAW Image Viewer's configuration dialog:

    RAWSupport.exe /configure

Source:

Tested with Microsoft RAW Image Viewer 1.1.50.0 on Microsoft Windows XP Professional SP2 (5.1.2600)

 

Back to the top of this page . . .

Mozilla Thunderbird

Get Thunderbird

Compose an e-mail message, including attachment:

	SET Recipients=to="Recipient",cc="CcRecipient",bcc="BccRecipient"
	SET Message=subject="MessageSubject",body="MessageBody"
	thunderbird.exe -compose %Recipients%,%Message%,attachment="FileToBeAttached"
Notes: The SET commands have been used to split up the command, otherwise the full command line for thunderbird.exe wouldn't fit in the browser window.
  Like the mailto: technique, you still need to press the "Send" button to actually send the message.

Open the address book:

	thunderbird.exe -addressbook

Sources with more details:

Not all command line switches listed in these sources will work in every Thunderbird version.

Tested with Mozilla Thunderbird 2.0.0.14 (20080421) on Microsoft Windows XP Professional SP2 (5.1.2600)

 

Back to the top of this page . . .

Sunbelt VIPRE Antivirus + Antispyware

Get VIPRE Antivirus + Antispyware

Run a Quick Scan:

	SBAMCommandLineScanner.exe /scannowquick

Run a Deep Scan:

	SBAMCommandLineScanner.exe /scannowdeep

Enable active protection:

	SBAMCommandLineScanner.exe /enableap

Update virus & spyware definitions:

	SBAMCommandLineScanner.exe /updatedefs

Display VIPRE software version:

	SBAMCommandLineScanner.exe /displayvipreversion

Display local virus & spyware definitions version:

	SBAMCommandLineScanner.exe /displaylocaldefversion

Source with more details:

Tested with VIPRE 3.1.1606.1 on Microsoft Windows XP Professional SP3 (5.1.2600)

 

Back to the top of this page . . .

Visio

Open a Visio file without showing the "splash screen":

	visio.exe VisioFile /nologo

Open the last opened file:

	visio.exe /1

Open Visio's print dialog:

	visio.exe /p VisioFile

Silently print a Visio file to any printer:

	visio.exe /pt VisioFile PrinterName [ DriverName [ PortName ] ]

Sources with more details:

Not tested

 

Back to the top of this page . . .

Microsoft Word

Open a Word document without "splash screen":

	winword.exe WordDocument /q

Open a Word document in safe mode:

	winword.exe WordDocument /safe

Open a new Word document based on an existing file:

	winword.exe /f WordDocument

Print a Word document:

Open Word and create a macro file with the following content (tested in Word 2007 English, you may need to tweak the code for other versions or languages):

Sub PrintDefault()
'
' PrintDefault Macro
' Print current document to Default Printer
'
	ActiveDocument.PrintOut
	ActiveDocument.Close
	Application.Quit
End Sub

Save the macro as "PrintDefault" in normal.dot. You only need to do this once.

Or download it here, and unzip and import it to normal.dot:

From now on, you can print a Word document using the following command:

	winword.exe WordDocument /mPrintDefault /q /n

This command opens WordDocument in Word, prints the document, closes it and exits Word.
The /q switch suppresses the "splash screen", the /n switch opens a new instance of Word, so WordDocument won't show up in the list of documents in any other open instance.
Unfortunately, I haven't found a way yet to hide Word from view during the process.

Notes: It is possible to create a macro that prints to an alternative printer instead of the default.
Save this macro giving it a logical name, and use that macro in the command to print to that alternative printer.

Using macro's on the command line opens up other possibilities too, like saving a file in a different format.
Have a go at it!

Sources with more details:

Tested with Microsoft Word 2007 (12.0.6308.5000) on Microsoft Windows XP Professional SP3 (5.1.2600)

 

Back to the top of this page . . .

Wordpad

Open a text file (any supported format) in Wordpad:

	write.exe TextFileName

Print a text file (any supported format) with Wordpad to the default printer:

	write.exe /p TextFileName

Print a text file (any supported format) with Wordpad to any printer:

	write.exe /pt TextFileName PrinterName [ DriverName [ PortName ] ]
Note: You may use either wordpad.exe or write.exe, both commands will start WordPad. The only difference is that write.exe is located in the %windir%\System32 directory, and hence doesn't need its fully qualified path specified.

Source:

Tested in Microsoft Windows XP Professional SP2 and SP3 (5.1.2600) and in Microsoft Windows 7 RC (64-bits) (6.1.7100)

 

Back to the top of this page . . .

WordPerfect

Open a file in WordPerfect, without showing the "splash screen":

	WPWin12.exe : WpFile

Print a WP file:

Open WordPerfect and create a macro file with the following content (tested in WordPerfect 12 English, you may need to tweak the code for other versions or languages):

Application (WordPerfect; "WordPerfect"; Default!; "EN")
PrintInColor (State: True!)
PrintGraphics (State: False!)
PrintWithDocumentSummary (State: False!)
PrintCopies (NumberOfCopies: 1)
PrintSortOrder (Order: Group!)
PrintDestination (Destination: DriverPort!)
PrintGraphically (State: False!)
PrintTwoSided (Option: LongEdge!)
PrintInReverseOrder (State: False!)
PrintBooklet (State: False!)
PrintAction (Action: FullDocument!)
Print ()
CloseNoSave ()
ExitWordPerfect ()

Save the macro as "PrintAndClose.wcm" in the default location. You only need to do this once.

Or download it here and unzip and save it in WordPerfect's default macro location:

From now on, you can print a WordPerfect file using the following command:

	WPWin12.exe : WpFile /M-PrintAndClose.wcm

This command opens WPFile in WordPerfect, prints the document, closes it and exits WordPerfect.
Unfortunately, I haven't found a way yet to hide WordPerfect from view during the process.

Notes: It is possible to create a macro that prints to an alternative printer instead of the default.
Save this macro giving it a logical name, and use that macro in the command to print to that alternative printer.

Using macro's on the command line opens up other possibilities too, like saving a file in a different format, or converting ("publishing") it to PDF...
Have a go at it!

Sources with more details:

Tested with Corel WordPerfect 12.0.0.602 on Microsoft Windows XP Professional SP2 (5.1.2600)

 

Back to the top of this page . . .

Microsoft XPS Viewer

Get Microsoft XPS Viewer

Open a file in XPS Viewer:

	    XpsRchVw.exe XpsFile

Load a file in XPS Viewer and open the Print dialog:

	    XpsRchVw.exe XpsFile /p

Convert an XPS file to multipage TIFF:

	    XpsRchVw.exe XpsFile /o:TiffFile.tif

Convert an XPS file to multiple PNG files:

	    XpsRchVw.exe XpsFile /o:PngFile.png

Tested with Microsoft XPS Viewer 1.0.6000.16438 on Microsoft Windows XP Professional SP2 (5.1.2600)

 

Back to the top of this page . . .

 

Samples:

Command line switches I haven't been able to verify yet:

Alternatives in case a program just won't print from the command line:

 

 


page last uploaded: 3 May 2012, 09:30