Les...Im trying to strip down the MS vbs script into a small kix script just for my own personal amusement...Except I cant get the $oEnum = oService.ExecQuery("select DeviceID from Win32_Printer where default=true") line to work. It just displays the select DeviceID from Win32_Printer where default=true in a command box. I know you do a lot of WMI so do you see anything wrong with it?
Code:
If GetDefault() = 0
? "Default Printer - "+$oPrinter.DeviceID
Else
? "Could Not Obtain Default Printer"
Endif
Get $
FUNCTION GetDefault()
$oLocator = CreateObject ("WbemScripting.SWbemLocator")
If Not $oLocator
Exit 1
Endif
$oService = $oLocator.ConnectServer(@WkSta, "root\cimv2")
If Not $oService
Exit 1
Endif
$oService.Security_.impersonationlevel = 3
$oEnum = oService.ExecQuery("select DeviceID from Win32_Printer where default=true")
For Each $oPrinter in $oEnum
$DefaultPrinter = $oPrinter.DeviceID
Next
ENDFUNCTION