taartero
asked on
Adding error codes to a VBS that needs to run from SCCM
The script I need help with is below. I am going to create a package that will run while a user is logged on that is a vbs script that will remove printers that match entries in the 'cases' in the script and then add the appropriate printer on a new server.
SCCM will report a successful error code as soon as the script executes. What I need are lines of code in the script that will report if the script actually replaced a printer; or if the script failed to run.
It would be even better if the script code could tell me which printers were replaced as well.
Set WshNetwork = WScript.CreateObject("WScr ipt.Networ k")
Set oPrinters = WshNetwork.EnumPrinterConn ections
WScript.Echo
WScript.Echo "Network printer mappings:"
For i = 0 to oPrinters.Count - 1 Step 2
WScript.Echo oPrinters.Item(i+1)
Select Case (oPrinters.Item(i+1))
Case "\\SERVER01\printer01":
wshnetwork.removeprinterco nnection oprinters.item(i+1), true, true
Case "\\SERVER01\printer02":
wshnetwork.removeprinterco nnection oprinters.item(i+1), true, true
wshnetwork.addwindowsprint erconnecti on "\\newSERVER01\printeraa"
Case "\\SERVER01\printer03":
wshnetwork.removeprinterco nnection oprinters.item(i+1), true, true
wshnetwork.addwindowsprint erconnecti on "\\newSERVER01\printerab"
End Select
Next
SCCM will report a successful error code as soon as the script executes. What I need are lines of code in the script that will report if the script actually replaced a printer; or if the script failed to run.
It would be even better if the script code could tell me which printers were replaced as well.
Set WshNetwork = WScript.CreateObject("WScr
Set oPrinters = WshNetwork.EnumPrinterConn
WScript.Echo
WScript.Echo "Network printer mappings:"
For i = 0 to oPrinters.Count - 1 Step 2
WScript.Echo oPrinters.Item(i+1)
Select Case (oPrinters.Item(i+1))
Case "\\SERVER01\printer01":
wshnetwork.removeprinterco
Case "\\SERVER01\printer02":
wshnetwork.removeprinterco
wshnetwork.addwindowsprint
Case "\\SERVER01\printer03":
wshnetwork.removeprinterco
wshnetwork.addwindowsprint
End Select
Next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
as i know everything except of 0 is an error when not executing a msi package
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Seems like a code limitation
ASKER