Archive for the ‘ VBScript ’ Category

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
objPrinter.Delete_
Next

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.

http://msdn.microsoft.com/en-gb/library/windows/desktop/aa394363(v=vs.85).aspx

http://www.scriptinternals.com/new/us/support/Internal/WMI_Win32_Printer.htm

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.

Print Friendly, PDF & Email

Check Windows 7 Activation Using VBS

So i had some issues trying to use windows activation and wanted to be able to report on the OS status using BGInfo.

My below script can be referenced  inside BGInfo.

I might be worth downloading WMI Code Creator v1.0 This can be used to show what other information is ready for the picking.

Editing the below script will be able to report on any of the records WMI can throw your way.

 

Copy and paste the following code into a new .vbs file


Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From SoftwareLicensingProduct")
Coltest = int(0)
IsWinActivated = True

For Each objitem In colItems
IF int(objitem.GracePeriodRemaining) = 0 Then Coltest = True else Coltest = False
IF Coltest = False then IsWinActivated = False
Next

IF IsWinActivated = False then
call echo "Failed"
ELSE
call echo "Successful"
END IF

Print Friendly, PDF & Email

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
Err.Clear
Else
sResults = sResults & sApplication & " Version: " & sTemp & vblf
End If
End Sub

Print Friendly, PDF & Email