Sunday, 11 March 2012

software to check avability,location and disconnect of printer

Configuring Printer Availability


Configures a printer so that documents can only be printed between 8 AM and 6 PM.
dtmStartTime= "********080000.000000+000"
dtmEndTime= "********180000.000000+000"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colPrinters = objWMIService.ExecQuery _
    ("Select * From Win32_Printer Where DeviceID = 'ArtDepartmentPrinter' ")
For Each objPrinter in colPrinters
    objPrinter.StartTime = dtmStartTime
    objPrinter.UntilTime = dtmEndTime
    objPrinter.Put_
Next

Configuring Printer Locations


Uses ADSI to configure the location attribute for all printers in a specified OU.
Set objOU = GetObject("LDAP://OU = Finance, DC = fabrikam, DC = com")
objOU.Filter = Array("printqueue")
For Each objPrintQueue In objOU
    objPrintQueue.Put "Location" , "USA/Redmond/Finance Building"
    objPrintQueue.SetInfo
Next

Configuring Printer Priority


Sets the priority for a printer to 2.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colPrinters = objWMIService.ExecQuery _
    ("Select * From Win32_Printer where DeviceID = 'ArtDepartmentPrinter' ")
For Each objPrinter in colPrinters
    objPrinter.Priority = 2
    objPrinter.Put_
Next

Deleting All Printers on a Print Server


Deletes all the printers from a print server.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer")
For Each objPrinter in colInstalledPrinters
    objPrinter.Delete_
Next

No comments:

Post a Comment