Windows Commands

I am using the following command to disconnect a mapped drive:

net use * /d

Continuing will cancel the connections.

Do you want to continue this operation? (Y/N) [N]:

I am prompted as above:

I want the choice of Y to be applied automatically

I tried the command echo Y|net use * /d

But I am not succeeded.

Need help how to pass Y for the above command so that it should not prompt the user to provide Y or N. Thanks

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kevin CrossChief Technology OfficerCommented:
It is probably because you are using *.
If you can, try:
NET USE <Drive Letter> /DELETE

Open in new window

net use * /delete /Y
net use * /d does not disconnect a mapped network drive. It disconnects all mapped network drives.
How much mapped drives do you have?
net use z: /delete      ---> goes flawless without confirmation question.
"C:\Users\peer>net use h: /d
h: was deleted successfully."

So unless you want to run a script to disconnect all "custom made" connections by users, i would use the disconnection per mapped drive.

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Kevin CrossChief Technology OfficerCommented:
If you do indeed want to do all mapped drives, do like this:

Open in new window

Kevin CrossChief Technology OfficerCommented:
Argh. I should have refresh, fellas, sorry. That was the point of my first post. The prompt for confirmation is due to doing ALL mapped drives. Doing one at a time works without prompt as also confirmed by peter197911. That was my point in first post if it was not clear. As shown by arnold, if you do want to do all drives it is /Y at the end. Not Y|.
Easy way to kill them all is

reg delete "hkcu\network" /f

Often gets the stubborn ones that wont delete with a net use command.....

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Legacy OS

From novice to tech pro — start learning today.

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.