Posts Tagged ‘ VBScript

VBS Clean Printer list

If your looking to delete all the printers via script this is your code.
You can change the SELECT to pick certain printers.

This .vbs can be deployed using GPO as a user login script.

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * From Win32_Printer Where ServerName = '\\\\servername'",,48)
For Each objPrinter in colInstalledPrinters

All Printers

("SELECT * FROM Win32_Printer")

All printers where they are offline

("SELECT * FROM Win32_Printer WHERE ExtendedPrinterStatus = 2")



For more select statements please compile them using the information below.

or search for “WMI Win32_Printer class”

Another useful tool is WMI Code Creator.
This will show you the values of current WMI records and build your select.

Check Registry Settings

Paste the following text into a .vbs file and edit as required.

The code allows you to check registry settings

On Error Resume Next

sResults = ""

Set oWShell = CreateObject("Wscript.Shell")
Call GetAppVersion("Internet Explorer", "HKLM\SOFTWARE\Microsoft\Internet Explorer\Version")
Call  GetAppVersion("Java",  "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{26A24AE4-039D-4CA4-87B4-2F83216016FF}\DisplayVersion")

msgbox sResults

Set oWShell = Nothing

Sub GetAppVersion(sApplication, sRegPath)
On Error Resume Next

sTemp = oWShell.RegRead(sRegPath)
If Err.Number <> 0 Then
sResults = sResults & "Version not found for " & sApplication & "." & vblf
sResults = sResults & sApplication & " Version: " & sTemp & vblf
End If
End Sub