Avatar of ddantes
ddantes
Flag for United States of America asked on

Automating a step in a batch file.

Running Windows 7 32-bit, I have a batch file in the Startup folder, which maps a network drive (V:) to Windows Explorer.  This is necessary, because the drive is a shared folder within a N.A.S.  Here is the batch file code:

net use V: \\V:\Data
net use V: \\DiskStation3\Data


Sometimes, after rebooting, the batch file won't complete without user interaction.  A question appears in the command window:  "V: has a remembered connection to \\Diskstation-3\Data.  Do you want to override the remembered connection?"


The answer is "no", and I'm wondering if there is code which can be added to the batch file to automate that response, if the question appears?


Windows OSWindows 7Networking

Avatar of undefined
Last Comment
ddantes

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
arnold

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ddantes

ASKER
Thank you.
CompProbSolv

When I do a "net use" command in a .CMD file to create a mapping, I usually precede it with a command to delete the map if it already exists.  In your case:
net use v: /delete
It will generate an error message if V: isn't already mapped, but it will continue executing.
ddantes

ASKER
Thank you, but I'm hesitant to add that feature.  The mapping would require credentials, once the map is deleted.  Unless that code is essential, I'd like to use the batch file as it is. 
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Qlemo

Removing the errornous line won't change the prompt if the drive is already mapped. You can use
net use Y: 2>nul >nul || net use Y: \\DiskStation3\Data 

Open in new window

to only map if there is no drive Y: yet.
ddantes

ASKER
Thank you, I will make that code adjustment!