I didn't know if I should start this topic under "Programming" but it seems to be the only place to put it.
I want to run a batch file that will automatically map a network drive before it continues the script. The problem I have is that if for some reason the drive is already mapped, or the batch file has been run twice in one session, the "net use" command returns an error. The script still works in the end, but I would like to bypass the "net use" command altogether if the drive is already mapped.
I've been digging through the net trying to find anything that can help me out, but to no avail. The closest thing I can find is just typing "net use" can tell you if the drive is already mapped or not, but I can't take any one piece of that result and use it in my script.
Does anyone have any suggestions? My purpose here is to write an IF statement that determines:
IF drive X: is already mapped, then skip net use command and proceed with the remainder of the script.
ELSE, run net use command and proceed with the remainder of the script.
I figured ERRORLEVEL could come in handy, but that only works after I get the error that I'm trying to avoid in the first place.
I absolutely hate how they are using intentionally misleading wording to scare people into "upgrading" their operating system. They could use the money they are spending on marketing to keep Windows 10 running for, like, 10 more years.
This tool is for ripping CDs not burning them. So it's to save cd audio tracks as files. Simple old tool to do it. For burning I used to use Nero Burning Tools back in the day rather than the ones you listed.
Recent Achievements
Vladimir Migunov earned a badge One Year In
daelos earned a badge One Month Later
daelos earned a badge Week One Done
Karlston went up a rank Mentor
EdwardFranciscoVilla earned a badge One Month Later
Question
Xtreme $niper
I didn't know if I should start this topic under "Programming" but it seems to be the only place to put it.
I want to run a batch file that will automatically map a network drive before it continues the script. The problem I have is that if for some reason the drive is already mapped, or the batch file has been run twice in one session, the "net use" command returns an error. The script still works in the end, but I would like to bypass the "net use" command altogether if the drive is already mapped.
I've been digging through the net trying to find anything that can help me out, but to no avail. The closest thing I can find is just typing "net use" can tell you if the drive is already mapped or not, but I can't take any one piece of that result and use it in my script.
Does anyone have any suggestions? My purpose here is to write an IF statement that determines:
IF drive X: is already mapped, then skip net use command and proceed with the remainder of the script.
ELSE, run net use command and proceed with the remainder of the script.
I figured ERRORLEVEL could come in handy, but that only works after I get the error that I'm trying to avoid in the first place.
Thanks!
Link to comment
https://www.neowin.net/forum/topic/616815-ms-dos-batch-automatically-determine-if-drive-is-already-mapped/Share on other sites
19 answers to this question
Recommended Posts