QB64.com

QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.

There are some Windows command line statements that allow one to (i) identify the current Windows default printer (as well as other printers associated with a PC) and (ii) change the default to a different printer.

A program can use SHELL statements in QB64 to execute those operating system commands. See the following examples provided by forum member DonW:

Contents


SHELL _HIDE "CMD /C" + "wmic printer get name,default > default.txt"

A sample of the contents of the resulting file is as follows. Notice that the default printer is listed as “TRUE”:


Default  Name                           
  FALSE    Microsoft XPS Document Writer 
  TRUE     HP Photosmart C7200 series     
  FALSE    HP Officejet Pro 8600         
  FALSE    Fax


SHELL _HIDE "CMD /C" + "wmic printer where name='HP Officejet Pro 8600' call setdefaultprinter" 

Then running the get default SHELL code again, we see the following contents of the text file:


Default  Name                           
  FALSE    Microsoft XPS Document Writer 
  FALSE    HP Photosmart C7200 series     
  TRUE     HP Officejet Pro 8600         
  FALSE    Fax

Now we see that the “HP Officejet Pro 8600” is marked as “TRUE”, and thus is now the default printer for LPRINT and _PRINTIMAGE.

Notes

See Also