Default Printer
This piece of code, simple as it is, took me a long while to develop. I am not well versed in Visual Basic and yet needed to find the default printer. I searched in a 1000+ page book, all over the internet, and after a lot of trial and error got it working. This Visual Basic script code block returns the default printer:
' Returns the default printer
Function GetDefaultPrinter()
Set WshShell = WSCript.CreateObject("WScript.Shell")
sRegVal = "HKCU\Software\Microsoft\Windows "
sRegVal = sRegVal & "NT\CurrentVersion\Windows\Device"
sDefault = ""
sDefault = WshShell.RegRead(sRegVal)
sDefault = Left(sDefault, InStr(sDefault, ",") - 1)
GetDefaultPrinter = sDefault
End Function