objdictionary = createcomobject("Scripting.Dictionary")
strcomputer = "."
objwmiservice = getobject("winmgmts:{impersonationLevel=impersonate}!\\" || strcomputer || "\root\cimv2")
colprinters = objwmiservice~execquery("Select * from Win32_Printer")
DO objprinter OVER colprinters
objdictionary~add(objprinter~portname, objprinter~portname)
END
strusedports = ""
strfreeports = ""
colports = objwmiservice~execquery("Select * from Win32_TCPIPPrinterPort")
DO objport OVER colports
IF objdictionary~exists(objport.name) = 1 THEN
strusedports = strusedports objdictionary~item(objport.name)
ELSE
strfreeports = strfreeports objport~name
END
SAY "The following ports are in use:" strusedports
SAY "The following ports are available:" strfreeports
|