Solved

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

Posted on 2008-10-03
3
251 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
[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
  • 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

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

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

Suggested Solutions

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

751 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