There are times as a developer you will need to run applications such as Visual Studio or SQL Server Management Studio as Administrator or as a Windows user under another domain account that your machine isn’t joined to. For example using
runas while connected to a VPN. One of the issues you may run into is the mapped drives you’ve set are no longer visible to the application because they are mapped to the user you’re logged into the machine as rather than the user you’re running the application as.
How To Make Mapped Network Drives Visible To All Users
To solve this issue, create a batch script to map the drives using the ‘net use’ command and execute it as a Startup script from the Local Group Policy.
Open a text editor and create the desired mappings with the
net use command with the option,
/persistent:yes. In this case I’m using VirtualBox and am mapping network drives on the host machine:
net use E: \\VBOXSVR\Code /persistent:yes
Save this as a batch script file using the
.bat file extension.
Note: When doing this in a virtual machine guest in VirtualBox, be sure the Auto-mount option for Shared Folders under VirtualBox settings is disabled as shown here. Having Auto-mount enabled while adding the new mapped drives will cause a double mapping of the drives for the user logging into the machine!
Open the Local Group Policy Editor.
Navigate to Local Computer Policy > Windows Settings > Scripts (Startup/Shutdown) and click Startup.
Under Startup Properties click Add… and select the ‘.bat’ file saved earlier.
After a reboot, you will now have the mapped drives available for not only the user logged into the Windows machine, they will also be available to any applications running under a different user such as Administrator or a user joined to another domain through VPN using the