While searching for Print and PrintTo commands in the registry under
HKEY_CLASSES_ROOT I found that for many file types the print commands use DDE instead of command line switches.
Take this Print command for WordPerfect 12 documents, for example:
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\WP12Doc\shell\print] [HKEY_CLASSES_ROOT\WP12Doc\shell\print\command] @="\"C:\\Program Files\\WP12\\wpwin12.exe\" /ddeex /smin :" [HKEY_CLASSES_ROOT\WP12Doc\shell\print\ddeexec] @="FileOpen(\"%1\") PrintFullDoc() CloseNoSave(1)" [HKEY_CLASSES_ROOT\WP12Doc\shell\print\ddeexec\application] @="wpwin12_Macros" [HKEY_CLASSES_ROOT\WP12Doc\shell\print\ddeexec\ifexec] @="FileOpen(\"%1\") PrintFullDoc() CloseNoSave(1)" [HKEY_CLASSES_ROOT\WP12Doc\shell\print\ddeexec\topic] @="Commands"
These registry settings define the actions that Windows and WordPerfect will take if a WordPerfect document is printed from its context menu (right-click, "Print").
The registered "Print" command's command line for any file type can be found under
HKEY_CLASSES_ROOT\FileType\shell\print\command as the default value (
If the key
HKEY_CLASSES_ROOT\FileType\shell\print\ddeexec does not exist, then the default value registered in
HKEY_CLASSES_ROOT\FileType\shell\print\command is the full print command, and it can be used in batch files.
My GetPrint.vbs uses this to list registered Print and PrintTo commands for all file types.
However, if the key
HKEY_CLASSES_ROOT\FileType\shell\print\ddeexec does exist, then the default value registered in
HKEY_CLASSES_ROOT\FileType\shell\print\command is a command to start the program as a DDE server, and the required DDE commands can be found under
Without third party tools, these DDE commands would be useless for batch files (except the registered "Open" command, which is used by the START command).
We're in luck, there are a couple of command line tools available to use these DDE commands:
ClassExec by Freddy Vulto is a well-documented command line utility to execute any command (not just DDE commands) associated with a file type or extension.
Use it to open, print, view or edit files, whatever action is registered for that file type in
On my computer, I have 3 programs that are capable to open .DOC files: Microsoft's Word Viewer, WordPerfect and OpenOffice Writer. The default is Word Viewer.
classexec.exe worddocument.doc --action print
will generate an error message, because my default program to open .DOC files is the Word Viewer, which doesn't have a registered print command.
If I would have had Microsoft Office installed, Word would have been the default program to print .DOC files, and thus the ClassExec command would have used Word to print the command without generating this error message.
classexec.exe worddocument.doc --action print --class .wpd
converts/opens worddocument.doc in WordPerfect (the program associated with .WPD files), prints the document to the default printer, and keeps WordPerfect opened.
classexec.exe worddocument.doc --action print --class .wpd --ifexec
does the same, but (sometimes) closes WordPerfect when the printing is finished.
classexec.exe worddocument.doc --action print --class .odt --ifexec
silently opens worddocument.doc in OpenOffice Writer (the program associated with .ODT files), prints the file and closes again.
classexec.exe worddocument.doc --action printto alternateprinter --class .odt --ifexec
silently opens worddocument.doc in OpenOffice Writer, prints the file to alternateprinter (not the default printer), and closes again.
I'm still trying to figure out DDE_run.exe's syntax.
This forum thread would suggest the following syntax:
DDE_run.exe -s application -t topic -n "ShortPathToCommand /optional_DDE_switches" -c "[DDE_commands]"
Based on this information, and the following registry settings for my Word Viewer...
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Wordview.Document.8\shell] @="Open" [HKEY_CLASSES_ROOT\Wordview.Document.8\shell\Open] @="&Open" [HKEY_CLASSES_ROOT\Wordview.Document.8\shell\Open\command] @="\"C:\\PROGRA˜1\\MICROS˜2\\OFFICE11\\WORDVIEW.EXE\" /n /dde" [HKEY_CLASSES_ROOT\Wordview.Document.8\shell\Open\ddeexec] @="[REM _DDE_Direct][FileOpen(\"%1\")]" [HKEY_CLASSES_ROOT\Wordview.Document.8\shell\Open\ddeexec\Application] @="Wordview" [HKEY_CLASSES_ROOT\Wordview.Document.8\shell\Open\ddeexec\Topic] @="System"
...I tried the following command, which worked:
DDE_run.exe -s Wordview -t System -n "C:\PROGRA~1\MICROS~2\OFFICE11\WORDVIEW.EXE /n /dde" -c "[REM _DDE_Direct][FileOpen(\"WordDocument.doc\")]"
But that's about the only DDE command I got working properly.
No luck trying to make this work to print WordPerfect files, so far.
Maybe Microsoft Word?
CMCDDE by Commence Corp. doesn't come with "real" documentation, but unlike DDE_run it will at least display on-screen help if invoked without command line arguments.
Unlike ClassExec and DDE_run, it requires a separate command to start the DDE server.
Based on the registry settings discussed above, this is the command to open a Word document in WordViewer:
START /MIN "" "C:\PROGRA~1\MICROS~2\OFFICE11\WORDVIEW.EXE" /n /dde CMCDDE.EXE WordView System "[REM _DDE_Direct][FileOpen(\"WordDocument.doc\")]"
CMCDDE supports the use of (temporary) "command files", text files with the DDE parameters, which may be useful if, for example, a file name has to be supplied by a different batch file.
|page last uploaded: 2018-12-02, 18:18|