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 * /D /Y REM
net use I: "\\172.30.2.6\C$" /user:"SERVERA\administrator" Pa$$w0rd$ /p:YES
net use J: "\\172.30.2.6\D$" /user:"SERVERA\administrator" Pa$$w0rd$ /p:YES
net use K: "\\172.30.2.6\F$" /user:"SERVERA\administrator" Pa$$w0rd$ /p:YES
net use L: "\\172.30.2.6\G$" /user:"SERVERA\administrator" Pa$$w0rd$ /p:YES
net use O: "\\172.30.2.7\C$" /user:"SERVERB\administrator" C0ntr3s3n4 /p:YES
net use P: "\\172.30.2.7\D$" /user:"SERVERB\administrator" C0ntr3s3n4 /p:YES
net use Q: "\\172.30.2.7\F$" /user:"SERVERB\administrator" C0ntr3s3n4 /p:YES
net use R: "\\172.30.2.7\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
NET USE * /D /Y REM

* : 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: \\172.30.2.6\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).
"\\172.30.2.6\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