Previously submitted on the CSDN FAQ, not through the search engine to search the CSDN FAQ, find a good time to find. Now CSDN FAQ only CSDN users to normal access, solid to blog.
http://faq.csdn.net/FAQUnfurl.aspx?id=216232
Q: The existing 50 computers need to map a network drive, the network mapping disk must be F disk. The problem is that some computers already have a local f disk, the need to replace the local F disk Letter J, and then map the network drive to the F disk. Because the computer is many, therefore wants to use the batch processing file to solve.
A:
---------------------------------------------------------------
You can use the DiskPart script
http://www.microsoft.com/technet/prodtechnol/windowsserver2003/zh-chs/library/ServerHelp/ Ca099518-dde5-4eac-a1f1-38eff6e3e509.mspx
Batch content:
Echo Select volume F >remove.txt
echo Remove >>remove.txt
diskpart/s Remove.txt >output.txt
NET use F: \\ip\dir
Set Vol=0
For/f "skip=6 delims= volume DiskPart successfully removed the drive letter or mount point. "%%i in (output.txt) do set vol=%%i
Echo Select volume%vol% >assign.txt
echo Assign >>assign.txt
DISKPART/S Assign.txt
Del Remove.txt
Del Assign.txt
Del output.txt
---------------------------------------------------------------
1, first remove the F disk letter, command If successful execution will output text to Output.txt
Diskpart> Select volume F Select the F disk, the successful words will have output display select a disk to assume: Volume 5
Diskpart> Remove the letter of the currently selected disk.
DISKPART/S Remove.txt >output.txt is to write DiskPart output to the output.txt.
2. Load Network disk
NET use F: \\ip\dir detailed usage think the landlord should be used, specifically help see Net helps
3, using Output.txt to obtain volume 5
For execution: Line over 6 lines, and the volume DiskPart successfully removed the drive letter or mount point. "Read the text as a delimiter, and then read the number 5 into the variable%%i and assign it to the Vol variable.
4, Reload Volume 5
Diskpart> Select Volume 5 Choose Volume 5, because we have removed the letter, so we can only use numbers, which is the role of output.txt
Diskpart> assign to remove the currently selected disk letter.