Solved

Need VB or HTA to create a printer then delete it

Posted on 2010-11-30
3
498 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
  • 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
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 how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

679 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