Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to add a message box to VBScript

Status
Not open for further replies.

mwilliamsess

IS-IT--Management
Dec 29, 2005
12
US
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.AddWindowsPrinterConnection "\\server\printer"
mkDef = msgbox ("Do you want HPLJ2200 to be your default printer?", 292, "Default Printer Status")
If mkDef = 6 Then
WshNetwork.SetDefaultPrinter
msgbox ("Printer HPLJ2200 Installed As Default Successfully.")
Else
msgbox ("Printer HPLJ2200 Installed Successfully.")
End If

This is a function that adds a printer connection that I have on a web page. When the users click a button it install the printer for them. I want a message box to display saying "Access is denied" if the user trys to install a printer they don't have access to. Any help?
 
ON ERROR RESUME NEXT
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.AddWindowsPrinterConnection "\\server\printer"
IF Err.Number <> 0 THEN
MSGBOX "Access Denied",16,"Denied"
ELSE
ON ERROR GOTO 0

mkDef = msgbox ("Do you want HPLJ2200 to be your default printer?", 292, "Default Printer Status")
If mkDef = 6 Then
WshNetwork.SetDefaultPrinter
msgbox ("Printer HPLJ2200 Installed As Default Successfully.")
Else
msgbox ("Printer HPLJ2200 Installed Successfully.")
End If
END IF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top