Difference between revisions of "Windows Printer Settings"

From QB64 Wiki
Jump to navigation Jump to search
imported>SMcNeill
(transfers the contents of duplicate page "Printing to different printers" to this one.)
imported>SMcNeill
m (-)
 
Line 1: Line 1:
There are some '''Windows "command line" statements''' that allow one to 1) identify the current Windows default printer (as well as other printers associated with a PC) and 2) then change the default to a different printer. And one can then issue "SHELL" statements in QB64 to execute those command statements.  See the following examples by member '''DonW''':
+
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.  
  
This code issues the command to display a PC's list of printers and routes the output to a text file...
+
A program can use [[SHELL]] statements in QB64 to execute those operating system commands. See the following examples provided by forum member '''DonW''':
 +
 
 +
 
 +
==Contents==
 +
* This code issues the command to display a PC's list of printers and routes the output to a text file:
 
{{CodeStart}}{{Cl|SHELL}} {{Cl|_HIDE}} "CMD /C" + "wmic printer get name,default > default.txt"
 
{{CodeStart}}{{Cl|SHELL}} {{Cl|_HIDE}} "CMD /C" + "wmic printer get name,default > default.txt"
 
{{CodeEnd}}
 
{{CodeEnd}}
  
The contents of the resulting file (from one of my PC's) is as follows...the default printer is listed as "TRUE":
+
A sample of the contents of the resulting file is as follows. Notice that the default printer is listed as "TRUE":
 
{{TextStart}}Default  Name                           
 
{{TextStart}}Default  Name                           
 
   FALSE    Microsoft XPS Document Writer  
 
   FALSE    Microsoft XPS Document Writer  
Line 13: Line 17:
 
{{TextEnd}}
 
{{TextEnd}}
  
Here is the code to set the default printer to the "HP Officejet Pro 8600"...
+
* Here is the code to set the default printer to the "HP Officejet Pro 8600" listed in the sample above:
  
 
{{CodeStart}}{{Cl|SHELL}} {{Cl|_HIDE}} "CMD /C" + "wmic printer where name='HP Officejet Pro 8600' call setdefaultprinter" {{CodeEnd}}
 
{{CodeStart}}{{Cl|SHELL}} {{Cl|_HIDE}} "CMD /C" + "wmic printer where name='HP Officejet Pro 8600' call setdefaultprinter" {{CodeEnd}}
  
Then running the get Default [[SHELL]] code again, we see the following contents of the text file:
+
Then running the ''get default'' [[SHELL]] code again, we see the following contents of the text file:
 
{{TextStart}}Default  Name                           
 
{{TextStart}}Default  Name                           
 
   FALSE    Microsoft XPS Document Writer  
 
   FALSE    Microsoft XPS Document Writer  
Line 25: Line 29:
 
{{TextEnd}}
 
{{TextEnd}}
  
Now we see that the "HP Officejet Pro 8600" is marked "TRUE", and thus is now the default printer for [[LPRINT]].
+
Now we see that the "HP Officejet Pro 8600" is marked as "TRUE", and thus is now the default printer for [[LPRINT]] and [[_PRINTIMAGE]].
 +
 
  
These SHELL commands work in Windows XP, 7, 8.1 and 10.
+
==Notes==
 +
* These SHELL commands work in Windows XP, 7, 8.1 and 10.
  
  

Latest revision as of 19:11, 14 October 2017

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

  • This code issues the command to display a PC's list of printers and routes the output to a text file:

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

  • Here is the code to set the default printer to the "HP Officejet Pro 8600" listed in the sample above:

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

  • These SHELL commands work in Windows XP, 7, 8.1 and 10.


See also


External Links



Navigation:
Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page