Jump to content
Sign in to follow this  
pcjunki

set default printer on a remote pc

Recommended Posts

pcjunki

i've googled and oogled all over the net to try and find some software to do what i want, and can't find it.

so, here i am....

here is my "goal of what i am looking for"

to remotely query a compuer (current user logged on) and list the current installed "local" and "mapped printers"

and be able to set a default printer

anyone know how to do this? or know of any free software to do this?

Share this post


Link to post
Share on other sites
UEZ

Try this:

$sHost = @ComputerName

$sDefaultPrinter = "Microsoft XPS Document Writer"
WMI_SetDefaultPrinter($sHost, $sDefaultPrinter)

Func WMI_SetDefaultPrinter($sHost, $sPrintername) ;coded by UEZ 2012
    Local Const $objWMI= ObjGet("winmgmts:{impersonationLevel=impersonate}!" & $sHost & "rootcimv2")
    If @error Then Return SetError(1, 0, 0)
    Local Const $oItemsList = $objWMI.InstancesOf("Win32_Printer")
    Local $oPrinter
    For $oPrinter In $oItemsList
        ConsoleWrite($oPrinter.Name() & @CRLF) ;print printers to console
    Next
    Local Const $oItems = $objWMI.InstancesOf("Win32_Printer Where Name='" & $sDefaultPrinter & "'")
    If $oItems.Count Then
        For $oPrinter In $oItems
            $oPrinter.SetDefaultPrinter()
        Next
    Else
        Return SetError(2, 0, 0)
    EndIf
EndFunc

Will set "Microsoft XPS Document Writer" as default printer if available.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
pcjunki

getting a error,

line1

unknown macro

Share this post


Link to post
Share on other sites
UEZ

Update your AutoIt version to latest one!

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
UEZ

Can you post the whole SciTE console output please?

I cannot believe that @ComputerName is an unknown macro.

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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  

×