Quote
:: MapDrive.cmd: Assign letters to Drives
:: ------------
:: Purpose: Automatic assignement of new letter to drives without reboot.
::
:: Parameters:
:: ----------
:: 1. Language ID (ENU, FRA, DEU, NLD,...). No default value, mandatory.
:: 2. TEST to do everything except the drives de/re-assignment. The log file
:: TMP_MAPDRIVE_date_time.LOG is created: you can display it to see the expected assignments.
:: The environment variables TMP_VOLDESC- show the assignments to be done.
:: 3. TempPath : Path where temporary files will be created. Default is current directory.
:: Path could be enclosed in quotes and could terminated by a backslsh.
:: This is the 2d parameter if the 1st one (TEST) is omitted.
::
:: Why this program?
:: ----------------
:: Because during unattended Windows installation, I didn't want to reassign
:: manually my drives (S: for Save, W: for my CD Writer, V: for my DVD, T: for
:: temporary data, U: for backups, G: for games,...)
::
:: How to use it?
:: -------------
:: 1. Create a file DRIVE.x on each drive to be reassigned as x:.
:: 2. On the system drive, create a file CDR.x where x is the letter to assign
:: the the CD reader[/writer]. For unattended installation, create this file
:: in $OEM$\$1\.
:: 3. In the same way, create a file DVD.x for the DVD reader[/writer] on the system drive.
:: 4. On the system drive, create a DRIVE-.x for each letter x that you don't want
:: to be assigned (= reserved letters for USB Key,...).
:: 5. For unattended Windows installation, (FRA for French,...)
:: add these lines in the file RunOnceEx.cmd
:: (they should be modified according to your situation):
:: SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx
:: REG ADD %KEY%\001 /VE /D "Modifying Drives Letters" /f
:: REG ADD %KEY%\001 /V 1 /D "%SystemDrive%\Install\MapDrive.cmd FRA >%SystemDrive%\MapDrive.log 2>&1" /f
:: or add one of these lines in CMDLINES.TXT (under [COMMANDS]):
:: "MapDrive.cmd FRA %SystemDrive%\Temp >%SystemDrive%\Temp"
:: "MapDrive.cmd FRA TEST %SystemDrive%\Temp >%SystemDrive%\Temp"
::
:: Before running:
:: --------------
:: - If your windows language is not in the language ID set (see above in the "Parameters", 1.),
:: you should have the correct value in the environment string STR2FIND.
:: To do that, you should put a part of the answer DISKPART display when you
:: try to modify a reassignable drive letter.
:: To find this string, execute the following (without the text in () which are comments):
:: DISKPART
:: LIST VOLUME
:: SELECT VOLUME x (select an n on-system drive)
:: ASSIGN LETTER d (the same as the current letter)
:: (DISPART display the message that you should take)
:: SELECT VOLUME y (select the system drive)
:: ASSIGN LETTER e (the same as the current letter of the system drive)
:: (DISPART display an error message telling you that you
:: ( cannot reassign the letter for a system drive, boot
:: ( drive or a drive qhere is the swap file)
:: EXIT
:: You should take a part of the first message which is not in the second
:: message, and stop the string on accentuated characters.
::
:: Notes:
:: -----
:: When run, MapDrive.cmd scans all the drives (volumes) for files matching
:: "\DRIVE.?". If the file "\DRIVE.d" is encountered on a volume, this volume
:: is reassigned with the letter "d:".
:: Do not forget that the system drive as well as the drive containing the page
:: file (and others) could not be reassigned.
:: You may also reassign CD/DVD letters by creating one or many files "\DVD.d"
:: and/or "\CDR.d" on the system drive.
:: You may also disable drive letters by creating one or many files "\DRIVE-.d"
:: on the system drive.
::
:: This script works on FAT32 and NTFS file system. this is not the case for
:: MOUNTVOL which accepts only NTFS. Furthermore, no reboot is required.
::
:: The drives which are already assigned to the "good" letter will not be removed
:: nor reassigned.
::
:: IMPORTANT: I am not responsible for any damage caused directly or indirectly
:: by this program. So, before using it, run this batch with TEST as second parameter.
:: -------------------------------------------------------------------------------
EDIT: If your Windows language is English, German, Dutch or French, you don't have to worry about all of that: just call
MapDrive ENU, or MapDrive DEU, MapDrive NLD or MapDrive FRA.

Current attachement version is 2008/08/04:
:: 2008/08/04 : Dutch language added (Thanks to Orcinus)
:: 2005/10/30 : Reassigning twice (to avoid bad assigning to a used letter)
:: 2005/10/28 : Try to keep the existing letters.
:: Group deasignments and reassignments.
_____________________________________________
Keywords: drive drives partition partitions letter letters volume volumes mapdrive drivemap diskpart change changing rename renaming modify modifying
Attached File(s)
-
MapDrive.cmd.txt (30.75K)
Number of downloads: 108
This post has been edited by mdes: 11 November 2009 - 03:50 PM



Help


Back to top








