How to use NET USE and fix related errors

NET USE command syntax:


net use [{devicename | *}] [\\computername\sharename[\volume] [{password | *}]] [/user:[domainname\]username] [/user:[dotteddomainname\]username] [/user:[username@dotteddomainname] [/home {devicename | *} [{password | *}]] [/persistent:{yes | no}] [/smartcard] [/savecred] [/delete] [/help] [/?]


Refer for more details: http://pcsupport.about.com/od/commandlinereference/p/net-use-command.htm


Examples of NET USE:

Net Use Command Examples:

net use * “\\server\my media” /persistent:no

In this example, net use command is used to connect to the my media shared folder on a computer named server. The my media folder will be mapped to my highest free drive letter [*], which for me happens to be y:, but I don’t want to continue mapping this drive every time I log on to my computer [/persistent:no].

net use e: \\usrsvr00123\test Ae123Ci /user:usr01\test123 /savecred /p:yes

Here’s a slightly more complicated example that you might see in a business setting.

In this net use example, I want to map my e: drive to the test shared folder on usrsvr00123. I want to connect as another user account I have [/user] by the name of test123 that’s stored on the usr01 domain with a password of Ae123Ci. I don’t want to map this drive manually every time I start my computer [/p:yes] nor do I want to enter my username and password each time [/savecred].

net use p: /delete



Error faced when automating NET USE using a batch file:


A batch file in written to create a mapped network drive to a NAS, then this bat file gets run on daily schedule and runs as SYSTEM. This was done to take backup from disk to NAS.

The problem faced is that batch file isn’t working correctly and hanging with the following message,

“s: has a remembered connection to \\192….\xyz. Do you want to overwrite the remembered connection? (Y/N) [Y]: “




The easiest solution to this is include the /y option to the net use command. Unfortunately the help (net use /?) does not mention this option but it works. The /y option works with most windows command-line utilities.


For e.g.,

net use /y z: \\\backup >> C:\mount.log



Think there is also a /n option if you want to auto-answer “No” to any questions. Test if you want to.


Solution Reference: http://forums.whirlpool.net.au/archive/1661684


Download PDF

About the Author: Nitin G

Indian born, trekker, biker, photographer, lover of monsoons. I've been working full time with SQL Server since year 2005 and blogs to post the content aquired during my research on new topics or fixing issues faced by me as a DBA while working in different kind of projects, hope some of my posts may helps others in SQLDBA community. Everything you read on my blog is my own personal opinion and any code is provided "AS-IS" with no warranties!

Leave a comment

Subscribe to this blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 263 other subscribers

Translate this blog!



December 2020
« Nov    

View Post by Categories

%d bloggers like this: