Friday, January 9, 2015

Mapping Servers Drives by using "Net use" with username and password DOS

Client Require that All drives from ServerA andS erverB to be mapped in ServerC

The client is implementing a new file server called ServerC, and he requires that all the drives from ServerA and ServerB to be visible in ServerC to do the migration of all the company data from SrvA and B to the serverC. Here's the scenario in image

I will make a table to assist me in the creation of the drives

Now I can comply the request by creating a script called: 'mapping.bat' in notepad or notepad++. As Follows:
net use I: "\\\C$" /user:"SERVERA\administrator" Pa$$w0rd$ /p:YES
net use J: "\\\D$" /user:"SERVERA\administrator" Pa$$w0rd$ /p:YES
net use K: "\\\F$" /user:"SERVERA\administrator" Pa$$w0rd$ /p:YES
net use L: "\\\G$" /user:"SERVERA\administrator" Pa$$w0rd$ /p:YES
net use O: "\\\C$" /user:"SERVERB\administrator" C0ntr3s3n4 /p:YES
net use P: "\\\D$" /user:"SERVERB\administrator" C0ntr3s3n4 /p:YES
net use Q: "\\\F$" /user:"SERVERB\administrator" C0ntr3s3n4 /p:YES
net use R: "\\\G$" /user:"SERVERB\administrator" C0ntr3s3n4 /p:YES

Script Explanation

In line number 1, we just clean all the "network drives" that can be in use

* : A comodin to says all drives.
/D : Short for /delete
/Y : Short for /yes (so the scripts doesn't require user's confirmation).

Note: If you have any map drives already mapped and you wouldn't wanna clear, then just comment (by adding REM at the start of the line) or delete this line.

In the following lines we do the mapping I will explain line 2:

net use I: \\\C$ /user:SERVERA\administrator Pa$$w0rd$ /p:YES

Net Use: Command used to connect network drives.
I: Drive to map (it should not be on use by any other hard drive or DVD,BLUERAY or network drive).
"\\\C$": Specified the IP of the computer and the resource C$, the "$" at the end means that you will need administrative privilegies.
/user:SERVERA\administrator this option specifies the local admin from that machine (it can be a domain\user as well).
Pa$$w0rd$ Specifies the password from the user
/p Specifies the persistent option

Please consider to donate and thank you very much for reading this.

No comments:

Post a Comment