dedri
asked on
vbs script is not executed
I have a vbs script which deletes printers and maps the new one from different server
When I run it on my computer it was working. But when I tried on a user PC computers there is a problem and nothing has happen. The script does not report any errors. But the settings that need to be changed with this script doesn't change.
I need an urgent help because the server1 has failed and I need to redirect the users to another print server
PCs are windowsXP SP3
When I run it on my computer it was working. But when I tried on a user PC computers there is a problem and nothing has happen. The script does not report any errors. But the settings that need to be changed with this script doesn't change.
I need an urgent help because the server1 has failed and I need to redirect the users to another print server
PCs are windowsXP SP3
strOldServer = "server1"
strNewServer = "server2"
strComputer = "."
Set WSHNetwork = CreateObject("WScript.Network")
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery("Select * from Win32_Printer")
strOldServer = prepServer(strOldServer)
strNewServer = prepServer(strNewServer)
For Each objPrinter in colInstalledPrinters
strName = objPrinter.Name
iPrinterLocation = InStr(UCase(objPrinter.Name),UCase(strOldServer))
If iPrinterLocation > 0 then
strPrinter = strNewServer & Right(strName, Len(strName) - Len(strOldServer))
objPrinter.Delete_
WSHNetwork.AddWindowsPrinterConnection strPrinter
If objPrinter.Default = True Then
WSHNetwork.SetDefaultPrinter strPrinter
End If
End If
Next
Function prepServer(strServer)
If Left(strServer, 2) <> "\\" then
strServer = "\\" & strServer
End If
If Right(strServer, 1) <> "\" then
strServer = strServer & "\"
End If
prepServer = strServer
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER