Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need VB or HTA to create a printer then delete it

Posted on 2010-11-30
3
Medium Priority
?
504 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 2000 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Employees depend heavily on their PCs, and new threats like ransomware make it even more critical to protect their important data.
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…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

704 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