Sign in to follow this  
Followers 0
swin4ort

how do I set a specific printer as default

11 posts in this topic

I want to use AutoIt to automate the process where a user runs:

- control panel

- printers

- right clicks on a specific printer

- Set as Default Printer

Share this post


Link to post
Share on other sites



I want to use AutoIt to automate the process where a user runs:

- control panel

- printers

- right clicks on a specific printer

- Set as Default Printer

Although it looks harder, it is actually easier to use COM objects to do that. Here is a Microsoft answer in VBScript, which is easy to translate to AutoIt. Your task is a really simple example, and so a good one to learn this on.

Take a shot at it and post you code (working or not) and you'll get plenty of help making it work.

:rolleyes:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

another approach.. or two

RunWait(@SystemDir & '\RunDLL32.EXE printui.dll,PrintUIEntry /HÛ   ][ÝÖÔ[Ü^H[YWI][ÝÉÌÎNÊoÝ÷ Úâ*.­æ¥,Ûh²0¡÷ÚºÚ"µÍØ[
    ][ÝÜ[ZK   ][ÝË  ][ÝÛÛI][ÝË ][ÝÔ[RQ[UÉ][òÂò¢gV÷C¶væBgV÷C²ÂÂò¢gV÷C·G"gV÷C²ÂÂò¢gV÷C·w7GÅÕ½Ðì°Ìäì½ä½¸ÅÕ½ÐìÌäìµÀìÀÌØíÍAÉ¥¹ÑÉ9µµÀìÌäìÅÕ½Ðìù;, _ 
    "int", @SW_SHOWNORMAL)

Stolen from great people...

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

another approach.. or two

8)

Give 'em a scipt and they print for a day...

Teach 'em to script and they code for life!

:rolleyes:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Give 'em a scipt and they print for a day...

Teach 'em to script and they code for life!

:rolleyes:

... as i see you write more code here lately than anyone else...

:rambo:

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

... as i see you write more code here lately than anyone else...

:rambo:

8)

But I'm trying to kick the habit, and here you are just being an ENABLER!

I'm reporting you to my AA* accountability partner**!

:rolleyes:

*AutoIt Anonymous

**SmOke_N


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Both solutions are a lot shorter and more elegant than the 50 lines I came up with using Danwilli's suggested starting point. However, for both I get:

Operation could not be completed. Either the printer name was typed incorrectly, or the specified printer has lost its connection to the server. For more information, click Help.

I carefully cut and pasted the printer name; so I don't think that is the problem.

I can still set and unset the printer using windows.

any ideas?

Share this post


Link to post
Share on other sites

Both solutions are a lot shorter and more elegant than the 50 lines I came up with using Danwilli's suggested starting point. However, for both I get:

Operation could not be completed. Either the printer name was typed incorrectly, or the specified printer has lost its connection to the server. For more information, click Help.

I carefully cut and pasted the printer name; so I don't think that is the problem.

I can still set and unset the printer using windows.

any ideas?

Weeellll... let's see some code, man! Don't know how to help till we see what you tried.

:rolleyes:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Weeellll... let's see some code, man! Don't know how to help till we see what you tried.

:rolleyes:

Share this post


Link to post
Share on other sites

Weeellll... let's see some code, man! Don't know how to help till we see what you tried.

:rolleyes:

RunWait(@SystemDir & '\RunDLL32.EXE printui.dll,PrintUIEntry /y /n "E225310nD"')

;also ....

$sPrinterName = "E225310nD"

DllCall("printui.dll", "none", "PrintUIEntryW", _

"hwnd", 0, _

"ptr", 0, _

"wstr", '/y /n "' & $sPrinterName & '"', _

"int", @SW_SHOWNORMAL)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0