Map Network Drive Without Logging In

Posted on 2005-03-30
Medium Priority
Last Modified: 2008-01-09
Is there a way to have a network drive mapped automatically when the computer boots without having to log in as a user?  I am setting up a NAS and I need to store documents that one program we use needs, however, the program needs to see a drive letter in order to run properly, it won't work with a UNC name.

How can I set this system up to map a drive when it boots so that I don't need to keep it logged on?

Question by:bornskir
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 12

Expert Comment

ID: 13664379
I am assuming the program which needs the mapping runs as a service.

The way this kind of problem is usually handled is to create a little service that runs a batch file or vb script to map the drive.  The main difficulty is that drive mapping is not a global operation - it depends on your user context.  So only the same service that maps the drive, or other processes in the same security context, will see the mapping.

Can the find a way to have the program/service which needs the mapping to execute a batch file or vb script?  


Author Comment

ID: 13664535
I'll have to find out more about this application then.  I can write a batch file that will use the net use command to map the drive, but I'm not sure about the username/security that will be needed.

To give you a brief description on the application, it uses an SQL database stored on the same server.  Users will run an executable through a share on this server.  The executable interacts with SQL as well as other stored documents.

I am going to have to try to figure out then what I will store where.  I may have to re-think using the NAS and trying to store everything locally.

I was also planning on doing something similar for a backup exchange server by using the NAS to store the database and other data, but since exchange needs to see a drive letter also, I will end up with the same issue most likely.

Expert Comment

ID: 13665287
What about using the Windows Scheduler to kickoff a batch file.? The batch file will map a drive using the net use command. The scheduler has an option to run a task "When my computer starts".

You can also try the net use /persistent:yes parameter but I think that it's user specific and only kicks in after logging in.
7 Extremely Useful Linux Commands for Beginners

Just getting started with Linux? Here's a quick start guide that has 7 commands that we believe will come in handy.


Expert Comment

ID: 13666431
net use x: \\servername\sharename

try that at the dos prompt.  If you get no errors, you're good -- just create a one-line batch file to run at startup.

I recommend Mike Lin's startup control panel, from which you can create (and manage) startup files.  http://www.mlin.net/StartupCPL.shtml

Note: to stop the above just type net use x:  /delete
LVL 12

Expert Comment

ID: 13667018

The drive mapping issue can be resolved, but there are other reasons not to store an Exchange or SQL database on a mapped share.    See http://support.microsoft.com/kb/31717c3 and http://support.microsoft.com/default.aspx?scid=kb;en-us;304261

For your specific situation, you need to understand exactly what process is going to be accessing the network device:  is it SQLServer (e.g. is it a stored procedure running the application programs),  or is it a seperate service running the application?   The whole problem is that your mapping must be accessible to the right process, and so should proably be executed by the same process/service.

Have fun
LVL 13

Expert Comment

ID: 13667062
If you want to map a drive to the machine at startup, map it as follows:
Open Notepad
Net USE X: \\servername\share     Replace the servername with the name of the server, and the share with the name of the share.

File --> Save as
Change filetype to all
Save the file in a basic scripts directory.
Copy the file.
In Administrative Tools --> Users and Computers, right click the OU in which the computers reside.
--> Properties --> Group Policy Tab
Create a new group policy and call it SQLscripts

Then, in Computer Configuration --> Windows Settings --> Scripts
Right click on Startup --> Properties --> Add button
Browse button
Right click in the window and paste the script
Click Open --> OK --> OK

The script will work after AD has replicated or after you from the cmd prompt on the workstation run gpupdate /force

The rel question here, though, is why doesn't the executable simply connect to the SQL server via a Named Pipe, ODBC, or by installing the SQL client on the workstations that need to connect?

It seems to me that the database can remain on the NAS.  The application should reside on the workstation; if not, the folder in which the application resides on the NAS should have local group permissions for the users as required.
Then, any user in the group who runs the app should be fine.

ONE MAJOR SECURITY NOTE: Do not include a runas in the script because the scripts reside in read only containers that prying eyes can find easily, and then a username and password will have run amuck.


Accepted Solution

bornskir earned 0 total points
ID: 13719570
So far, nothing has worked.  I have tried setting up a batch file in task manager to perform a net use during startup, and I have tried using a start up script in a group policy.  As far as I can tell, the drive is not being mapped.  When I log on as a user locally, I do not have the drive mapped.

I have not tried the service method yet as I am not sure about the security.

I have found another method that may work.  I'm not thrilled about it, but I found a small program that sets the system to auto log on.  If I set that up to log on as a specific user and have that user with the drive mapped, I should be OK.

Thank you all for the suggestions.

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will learn how to backup a VMware farm using Nakivo Backup & Replication. In this tutorial we will install the software on a Windows 2012 R2 Server.
Many businesses neglect disaster recovery and treat it as an after-thought. I can tell you first hand that data will be lost, hard drives die, servers will be hacked, and careless (or malicious) employees can ruin your data.
This video teaches viewers how to encrypt an external drive that requires a password to read and edit the drive. All tasks are done in Disk Utility. Plug in the external drive you wish to encrypt: Make sure all previous data on the drive has been …
This tutorial will walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…
Suggested Courses
Course of the Month10 days, 9 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question