HP DesignJet T3500 System Administrator s Guide - Page 37
If TempPrintName = Printname and objPrinter.Shared = False then
View all HP DesignJet T3500 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 37 highlights
HP DJ UPD SAG Public Function CheckPrinterName(printerName) Dim index, candidateName candidateName = printerName index = 0 While CompareName(candidateName) index = index + 1 candidateName = printerName + " (Copy " + Cstr(index) + ")" Wend printerName = """" + candidateName + """" end function This function returns 1 if printer name already exists. Otherwise it returns 0 ' Input Params: ' - printerName: The name of the printer to compare Public Function CompareName(printerName) Dim WshNetwork, objPrinter,colInstalledPrinters, objWMIService Set WshNetwork = CreateObject("WScript.Network") Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") Set colInstalledPrinters = objWMIService.ExecQuery("Select * from Win32_Printer") For Each objPrinter in colInstalledPrinters if (objPrinter.Name = printerName) then CompareName = 1 exit function end if Next CompareName = 0 end function This function allows the to set the printer sharing ' Input Params: ' - PrintName: The printer name you want to share ' Output Parms: ' - N/A Function SharePrinter (Printname) dim objWMIService dim colInstalledPrinters dim objPrinter dim msg dim PrintNewStatus dim TempPrintName PrintNewStatus = True Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2") Set colInstalledPrinters = objWMIService.ExecQuery ("Select * from Win32_Printer") For Each objPrinter in colInstalledPrinters TempPrintName = """" + objPrinter.Name + """" If TempPrintName = Printname and objPrinter.Shared = False then objPrinter.Shared = PrintNewStatus objPrinter.ShareName = objPrinter.Name On Error Resume Next 37