I'm new to the vbs world, but have a background in PHP. Based on the Mark's FAQ ( I've put this together, but seem to be missing something somewhere.
Ideally, what I'd like to do is cycle through the networked printers installed on a workstation. If it finds a specific printer installed, it should remove it, and install a printer from a different server. Basically, we're migrating from one server to another. So I'm essentially going to just have a loop for each printer I need to deal with (about 8). Here is what I have:
That does not pass the IF statement, so nothing happens, including no visible errors.
I'm hardcoding the printer names only because they actually change names on the new server.
In a perfect world, I'd like to detect the current default printer so that when I replace it with the printer on the new server, I can set the new default. But that's just a wish.
Ideas as to what I'm doing wrong?
Pat Richard, MCSE(2) MCSA:Messaging, CNA(2)
Ideally, what I'd like to do is cycle through the networked printers installed on a workstation. If it finds a specific printer installed, it should remove it, and install a printer from a different server. Basically, we're migrating from one server to another. So I'm essentially going to just have a loop for each printer I need to deal with (about 8). Here is what I have:
Code:
ON ERROR RESUME NEXT
Dim WSHShell, WSHNetwork, Path
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
Set WSHPrinters = WSHNetwork.EnumPrinterConnections
For LOOP_COUNTER = 0 To WSHPrinters.Count - 1 Step 2
If WSHPrinters.Item(LOOP_COUNTER +1) = "\\old2003\4050South" Then
WSHNetwork.RemovePrinterConnection "\\old2003\4050South",True,True
WSHNetwork.AddWindowsPrinterConnection "\\new2003\4050North"
End If
Next
'Clean Up Memory We Used
set WSHNetwork = Nothing
set WSHSHell = Nothing
Set WSHPrinters = Nothing
'Quit the Script
wscript.quit
That does not pass the IF statement, so nothing happens, including no visible errors.
I'm hardcoding the printer names only because they actually change names on the new server.
In a perfect world, I'd like to detect the current default printer so that when I replace it with the printer on the new server, I can set the new default. But that's just a wish.
Ideas as to what I'm doing wrong?
Pat Richard, MCSE(2) MCSA:Messaging, CNA(2)