Jump to content

set default printer on a remote pc


Recommended Posts

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?

Link to post
Share on other sites

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to post
Share on other sites

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...