Shellexecute – Printing with the default application

This script prints the file in the first argument with the windows default application.


If you save the code in the file test.doc -> Opens Microsoft Word (if it is installed) and prints the file to the default printer. mytextfile.txt -> Same. But prints with Notepad

from win32api import ShellExecute
from sys import argv

ShellExecute(0, "print", argv[1], None, "", 1)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.