Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 261
  • Last Modified:

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

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
Bonnie_K
Asked:
Bonnie_K
  • 2
1 Solution
 
Steve KnightIT ConsultancyCommented:
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
 
Bonnie_KAuthor Commented:
Thanks!
0
 
Steve KnightIT ConsultancyCommented:
no prob
Steve
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now