Solved

batch file to add printer and delete printer

Posted on 2009-05-15
5
3,119 Views
Last Modified: 2013-11-10
i need to write a batch that will add a shared printer on boot up and then delete that same printer on  shutdown. This will go on a vista client...any idea?
0
Comment
Question by:richardjones1025
5 Comments
 
LVL 3

Expert Comment

by:cclassen
ID: 24399392
if you run logon and logoff scripts (controlled through group policy)
in login script
net use \\printservername\printername

in logoff script
net use \\printservername\printername /d
0
 

Author Comment

by:richardjones1025
ID: 24399495
C:\Documents and Settings\Richard Jones>net use \\ga1\Canon6 /delete
The network connection could not be found.

More help is available by typing NET HELPMSG 2250.
0
 
LVL 21

Accepted Solution

by:
AmazingTech earned 125 total points
ID: 24399677
logon script

rundll32 printui.dll,PrintUIEntry /in /n\\server\printer

logoff script

rundll32 printui.dll,PrintUIEntry /dn /n\\server\printer

PrintUIEntry is case sensitive.
0
 
LVL 8

Assisted Solution

by:JT92677
JT92677 earned 125 total points
ID: 24451483
The command

C:\Documents and Settings\Richard Jones>net use \\ga1\Canon6 /delete

should be

C:\Documents and Settings\Richard Jones>net use lpt1: /delete

The "/D? switch in the net use removes the connection between the device (LPT1:) and whatever it is connected to (which once connected, is known by the Operating system)

The other parts of the solution look fine, but the /Delete switch is applied only to the device, not to the path.

Hope this helps.

Jeff



0
 

Author Closing Comment

by:richardjones1025
ID: 31582058
both solutions work
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

705 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

20 Experts available now in Live!

Get 1:1 Help Now