Pages

Tuesday, 19 June 2012

Set Default Printer + VBScript

Use following script to set default printer




On Error Resume Next
Const HKCU = &H80000001
dim osh, var
dim regval, Sh, keyname
Dim objReg
Dim strcomputer


strcomputer="."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")


strKeyPath = "Software\Microsoft\Windows NT\CurrentVersion\Windows"


objReg.EnumValues HKCU, strKeyPath, arrSubKeys, arTypes
var="0"
For Each subkey In arrSubKeys
keyname = strkeypath & "\" & subkey
if (keyname = strkeypath & "\" & "Device") then
var="1" 
end If
Next

if var="0" then
objReg.SetStringValue HKCU, strKeyPath, "Device", "FACSys Fax Printer,winspool,Ne00:"
end if


Set oSH = nothing

No comments:

Post a Comment