PayPal is the easiest way to receive money online. Get one now or Click here to sign up. Sign up for PayPal and start accepting credit card payments instantly.

A collection of Command Line Switches

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

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 . . .

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 . . .

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 . . .

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" PdfFile /p

Print a PDF file silently to an alternative printer:

    "Foxit Reader.exe" PdfFile /t PrinterName
Notes: The /p and /t switches are case sensitive, the -n switch is not.

Source with more details:

Tested with Foxit Reader 2.3 Build 2923 on Microsoft Windows XP Professional SP2 (5.1.2600)

Back to the top of this page . . .

Internet Explorer

Open Internet Explorer without the home page:

    iexplore.exe -nohome

Open Internet Explorer in Windows Explorer mode:

    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.

Open Internet Explorer in kiosk mode:

    iexplore.exe -k [ url ]

Source with more details:

Tested with Internet Explorer 5..7 in Microsoft Windows 2000 & XP Professional

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:

  • All Command Lines
  • IrfanView help file (HH.EXE "mk:@MSITStore:C:\Program%20Files\IrfanView\i_view32.chm::/hlp_command_line.htm")

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

Back to the top of this page . . .

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

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

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

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:

Tested with NeroCmd version 1.9.0.1/Nero API version 6.6.0.19 on Microsoft Windows XP Professional SP2 (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

Open a file in OpenOffice:

    soffice.exe OpenOfficeFile

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

Source:

Tested with OpenOffice.org 2.4.0 on Microsoft Windows XP Professional SP2 (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

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 . . .

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:

  • The RAWSupport.exe /? command

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

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 . . .

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 . . .

Wordpad

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

    wordpad.exe TextFileName

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

    wordpad.exe /p TextFileName

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

    wordpad.exe /pt TextFileName PrinterName [ DriverName [ PortName ] ]

Source:

  • The /p switch was an "educated guess", the /pt switch was found using the command STRINGS wordpad.exe

Tested in Microsoft Windows XP Professional SP2 (5.1.2600)

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

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

Convert an XPS file to multiple PNG files:

        XpsRchVw.exe XpsFile /o:PngFile

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 . . .


Original Post Here


No comments:

WebProNews Feed

eWeek - RSS Feeds

HowtoForge - Howtos and Tutorials

The Register

PayPal is the easiest way to receive money online. Get one now or Click here to sign up. Sign up for PayPal and start accepting credit card payments instantly.