Solved

Need VB or HTA to create a printer then delete it

Posted on 2010-11-30
3
496 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
Comment Utility
Try this vb script
0
 
LVL 3

Expert Comment

by:raiERB
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
The viewer will learn how to dynamically set the form action using jQuery.

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now