Hi,
I'm trying to do a login vbs script that deletes a printer if it exists on
the machine. I can delete the printer if it exists OK, so that the first
time a user logs on, all is well. However, the next time the script runs, I
get an error stating:
"This network connection does not exist"
What I want to do is put an if exists statement around the deletion, so that
if it isn't there, the script doesn't try to delete it.
The script so far looks like:
strPrinter="\\DC2\Development"
Set WshNetwork = CreateObject("WScript.Network")
Set WshShell = CreateObject("WScript.Shell")
WshNetwork.AddWindowsPrinterConnection strPrinter
WshNetwork.SetDefaultPrinter strPrinter
MsgBox strPrinter & " Printer connected and set as the default printer"
Set WshNetwork = WScript.CreateObject("WScript.Network")
PrinterPath = "\\DC2\Engineering"
if Exists (PrinterPath) Then
WshNetwork.RemovePrinterConnection PrinterPath, true, true
MsgBox PrinterPath & " Printer Removed"
MsgBOx "Default printer is now " & strPrinter
End If
This errors with a Type Mismatch: 'Exists'
What am I missing her? Can anyone help?
Thanks
John