Solved

Need to use batch file to check if lpt2 is already mapped

Posted on 2008-10-03
3
248 Views
Last Modified: 2010-04-16
Hi,

I want to edit our login script to add a printer mapping for lpt2.

After it is done, I do not want it to remap every time the user logs in.

Is there a way to check if the port is mapped and skip the mapping?

THanks,
Bonnie
0
Comment
Question by:Bonnie_K
  • 2
3 Comments
 
LVL 43

Accepted Solution

by:
Steve Knight earned 500 total points
ID: 22637394
You could use the fact that the command
net use lpt2: either returns an error if it isn;t connected or some text if it is:
It also set the error level so you could check with

@echo off
net use lpt2: >NUL 2>&1
if "%errorlevel%"=="0" ( echo LPT2: is already mapped ) ELSE (
net use lpt2: \\jamie\spool
echo Mapped the LPT2: for you now
)
0
 

Author Comment

by:Bonnie_K
ID: 22637553
Thanks!
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 22637608
no prob
Steve
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

774 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