Solved

Need VB or HTA to create a printer then delete it

Posted on 2010-11-30
3
501 Views
Last Modified: 2012-05-10
I have a custom scenario where a user needs to connect to an IPP printer (http://99.99.99.99:631), then the user will print to the printer, then will need to disconnect or delete the printer.  So I need either a VB script or an HTA that the user can execute that will create the printer, then provide a desktop button that the user can click to disconnect or delete the printer after the user is done printing to it.  
0
Comment
Question by:murryc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 3

Expert Comment

by:raiERB
ID: 34246011
Try this vb script
0
 
LVL 3

Expert Comment

by:raiERB
ID: 34246014
Code was not attached to my message... here the script:
On Error Resume Next
Dim wshNet     : Set wshNet = CreateObject("WScript.Network")
Dim strPrinter : strPrinter = "http://99.99.99.99:631"

wshNet.SetDefaultPrinter strPrinter
If Err Then
  wshNet.AddWindowsPrinterConnection strPrinter
  wshNet.SetDefaultPrinter strPrinter
End If
On Error GoTo 0

Open in new window

0
 
LVL 3

Accepted Solution

by:
raiERB earned 500 total points
ID: 34246091
To remove the same printer use the following code:


On Error Resume Next
Dim wshNet     : Set wshNet = CreateObject("WScript.Network")
Dim strPrinter : strPrinter = "http://99.99.99.99:631"

wshNet.RemovePrinterConnection strPrinter, True, True
On Error GoTo 0

Open in new window

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question