Monday, April 20, 2009

Map a shared network drive on a domain with a batch file

This is the scenario: You have VPN access to a LAN running on a Windows domain. Once you connect through the VPN you don’t want to remote desktop to a machine but you still need access to the shared network drives that you would get via active directory.

So the easiest solution is to create a batch file that will map to to where the shared drive is using proper Windows authentication across the domain. This is what you need in the batch file.

NET USE Z: \\targetIP\drivename password /USER:domain\username /SAVECRED /PERSISENT:YES

So for How To Solutions it could be something like…

NET USE Z: \\192.168.0.1\solutions$ passw0rd /USER:HowToSolutions\admin /SAVECRED /PERSISENT:YES

This assume that…

192.168.0.1 - This is the local IP address of the target machine sharing the drive.
solutions$ - Is the name of the folder on the target machine.
passw0rd - Is the password used for your username.
HowToSolutions - This is the Windows domain you’ve VPN’d to.
admin - Is the username of the Windows account
SAVECRED - To use credentials previously saved by the user
PERSISTENT:YES - This will connect the share the next time you logon.
Put the single line in Notepad or something similar and save it as connect.bat. Now whenever you connect remotely to a network you can access the shared drives. It will use your Windows credentials so make sure you have sharing permissions on any folder/subfolders you try and access.

ref: http://how-to-solutions.com/map-shared-network-drive-on-domain-with-a-batch-file.html

No comments: