Printer Scripts for Windows Seven

I have been onto a site recently, and had issues with the Group Policy Preferences not applying to the printers. I found out that this was due to the time it takes the printer to respond to the request to be “mapped” and made default.

I spent a few hours and hacked around some code and came up with this little masterpiece to allow multiple room printers to be added to the relevant OU based PC

‘—————Delete all Printers————————————————–
Dim wshNetwork, sPrintPath, clPrinters, i
Set wshNetwork = CreateObject(“WScript.Network”)

‘Remove Existing Printers
Set clPrinters = wshNetwork.EnumPrinterConnections
On Error Resume Next
For i = 0 to clPrinters.Count – 1 Step 2
wshNetwork.RemovePrinterConnection clPrinters.Item(i+1), true
Next
On Error Goto 0

‘—- For citrix script, un-comment following two lines:

‘Set Sh = CreateObject(“WScript.Shell”)
‘sys = Sh.ExpandEnvironmentStrings(“%CLIENTNAME%”) ‘sys= the returned workstation name (Citrix only)

‘—- For normal Windows machines un-comment the following line

sys = wshNetwork.ComputerName ‘sys = computer name (standard domain workstations – not citrix)

‘—- Note, you can’t have both of these uncommented!!!

‘User = CreateObject(“WScript.Network”).Username ‘ This returns the logged on username to variable: User

‘—————————————————————————————————————

CName = UCase(sys) ‘Get name from network object (Uppercase)
Set oNet = CreateObject(“WScript.Network”)

‘ -=( Add printer and set a default based on computer name (CName) )=-

‘ Test for Left(CName,NumberofChars)

‘ WEST BLOCK SCRIPTS

if Left(CName,3) = “W21” Then

oNet.AddWindowsPrinterConnection “\print-serverw21-mono”
oNet.AddWindowsPrinterConnection “\print-serverw21-colour”
oNet.SetDefaultPrinter “\print-serverw21-mono”

Elseif Left(CName,3) = “W22” Then

oNet.AddWindowsPrinterConnection “\print-serverw22-Mono”
oNet.AddWindowsPrinterConnection “\print-serverw22-Colour”
oNet.SetDefaultPrinter “\print-serverw22-mono”

etc etc

end IF

iOS5

Updated a few of my iDevices tonight. No real revolution , just a miriad of evolutions.

DelProf2

GiraffeIT.com was called into a site to help diagnose some GPO not working quite how they were expecting.
Long of the short is a locally cached copy of the profile was being stored on the local machines. There are a few settings you can use in Windows 2008R2 to prevent the cached copy staying on the machine for more than x days. However for completeness I wanted the profiles gone there and then. Cue DelProf2. ( available here ) A few tweaks and a rough and ready batch file called via a startup trigger in a GPO and voila. No more cached local profiles at machine turn on.

New Blog !

We hope to add more of GiraffeIT real world experiences in here. I hope to share some of the issues and solutions that the herd have met and overcome.

GiraffeIT – sticking our neck out so you dont have to