MSFN Forum: Reassigning drive letters automatically - MSFN Forum

Jump to content



  • 8 Pages +
  • 1
  • 2
  • 3
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

Reassigning drive letters automatically Batch to do the job Rate Topic: -----

#1 User is offline   mdes 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 343
  • Joined: 07-November 03

  Posted 18 April 2004 - 03:51 PM

Here is the batch description:

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.


Posted Image

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)


This post has been edited by mdes: 11 November 2009 - 03:50 PM



#2 User is offline   titou2k 

  • Khayman
  • PipPip
  • Group: Members
  • Posts: 138
  • Joined: 02-March 04

Posted 18 April 2004 - 05:03 PM

Good job, i quickly read the script and i understand how it works. I will test it next time.

But for non french version, there is a problem
Line 99 you use --> FIND /C "La lettre sp"
The string is in french so in other language version, the string won't be find.

A+

#3 User is offline   mdes 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 343
  • Joined: 07-November 03

  Posted 18 April 2004 - 11:50 PM

titou2k, on Apr 19 2004, 12:03 AM, said:

But for non french version, there is a problem
Line 99 you use -->  FIND /C "La lettre sp"
The string is in french so in other language version, the string won't be find.

You are right :) I added comment in the post and in the batch file to tell how to change this string.

#4 User is offline   yourtech 

  • Member
  • PipPip
  • Group: Members
  • Posts: 116
  • Joined: 17-April 04

Posted 19 April 2004 - 12:48 AM

Awesome!!!! :rolleyes:

Funny how i was only just looking into this yesterday heh.

muchos gracias!!

I'm sure alot of other ppl will be quite happy to find this one also. :D

now honestly, is it reliable? :)

#5 User is offline   mdes 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 343
  • Joined: 07-November 03

  Posted 19 April 2004 - 02:17 AM

yourtech, on Apr 19 2004, 07:48 AM, said:

now honestly, is it reliable? :rolleyes:

Yes it has been tested :D
The only problem I encountered is that, sometimes (it depends of the installed Windows), the CD drive is not reassigned when there is a CD in the tray. I found why: the output file of DISKPART is UNICODE, so there is 2 characters at the file beginning. I will solve this problem in a few hours :)

EDIT: Sould be solved now: This was not a UNICODE problem but LF instead of CRLF.

This post has been edited by mdes: 19 April 2004 - 03:48 PM


#6 User is offline   R600 

  • Member
  • PipPip
  • Group: Members
  • Posts: 219
  • Joined: 07-August 03

Posted 19 April 2004 - 02:51 AM

Got one in Anglais?? hehe :)

#7 User is offline   mdes 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 343
  • Joined: 07-November 03

Posted 19 April 2004 - 03:41 PM

R600, on Apr 19 2004, 09:51 AM, said:

Got one in Anglais?? hehe :rolleyes:

Try as described above (DISKPART) and put the result as a post :)
:D :D

#8 User is offline   yourtech 

  • Member
  • PipPip
  • Group: Members
  • Posts: 116
  • Joined: 17-April 04

Posted 21 April 2004 - 11:24 PM

I've tried running this on a Ghost 8 PC-dos boot disk (floppy) to boot to a lan mount of the Install/Windist dir,

it no worky fo me

I get this spew about

"Out of environment space"
"Bad command or filename"

can someone explain how to run this mapdrive.cmd on an unattended install
(obviously prior to install so my D and E are in the right place)

I'm trying to accomplish this on a dual boot (xp/2K) machine :)
(2 C:'s (each hidden from each other), 2 D:'s, and 1 E:)

#9 User is offline   mdes 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 343
  • Joined: 07-November 03

  Posted 22 April 2004 - 12:31 AM

Yes, MapDrive.cmd use a lot a environment space :) Here is a solution:
In CONFIG.SYS, add the following line
shell=C:\cmd.com /P /E:nnn
where n is the number of bytes you want to set aside for the environment. For DOS 6.22 nnn represents the number of bytes you want to set aside. So for a 2K environment take nnn=2048 (try with a larger value, e.g. 8192 or more)
About ""Bad command or filename", I suppose this is a consequence of the out of environement space.

For unattended, I am using the following:
File command.txt
[COMMANDS]
RunOnceEx.cmd"
File RunOnceEx.cmd
SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx
...
REG ADD %KEY%\800 /VE  /D "Modifying Drives Letters" /f
REG ADD %KEY%\800 /V 1 /D "%systemdrive%\Install\MapDrive.cmd" /f
...


#10 User is offline   yourtech 

  • Member
  • PipPip
  • Group: Members
  • Posts: 116
  • Joined: 17-April 04

Posted 22 April 2004 - 12:38 AM

mdes, on Apr 22 2004, 12:31 AM, said:

shell=C:\cmd.com /P /E:nnn


Thanks eh! :)

saw that on one of my anicent config.sys's, was wondering what that was lol

question: is that ram or cache and how far could you go with say:

256K cache=?
512K cache=?
256Meg Ram=?
1024Meg Ram=?

Quote

File RunOnceEx.cmd


Didn't know it could be run that late in the game eh. Awesome :rolleyes:
(but before anything else of course)

#11 User is offline   yourtech 

  • Member
  • PipPip
  • Group: Members
  • Posts: 116
  • Joined: 17-April 04

Posted 22 April 2004 - 02:02 AM

k not getting any environment errors,

(although 8192 might be a little high; and it stopped NET.exe from from doing something, I still got in.)

but still getting syntax erros and bad command or filename
(repeated about 20-30 times)

just tried running diskpart

says it cannot be run under dos

so i guess its the runonceex method eh

question about that then,

Won't I need it to run before the os even gets installed so that my folder redirections will work?

http://groups.msn.com/MicrosoftWindowsXPRe...464671898804519

http://www.microsoft.com/WindowsXP/expertz...2/honeycutt.asp

or is the 12/13minute mark going to be ok for that?

(runonceex launched from/in commandlines.txt) or is it going to have to be put someplace sooner?

#12 User is offline   yourtech 

  • Member
  • PipPip
  • Group: Members
  • Posts: 116
  • Joined: 17-April 04

Posted 22 April 2004 - 02:17 AM

doh! n/m just stuck it 2nd in the list. :)

REG ADD %KEY%\001 /VE /D "Turning system restore off" /f
REG ADD %KEY%\001 /V 1 /D "REGEDIT /S Z:\SCRIPTS\sysresoff.reg" /f

REG ADD %KEY%\002 /VE  /D "Modifying Drives Letters" /f
REG ADD %KEY%\002 /V 1 /D "Z:\SCRIPTS\MapDrive.cmd" /f

REG ADD %KEY%\003 /VE /D "Setting Personal & Settings Folders Redirects" /f
REG ADD %KEY%\003 /V 1 /D "REGEDIT /S Z:\SCRIPTS\Redirect.inf" /f


that should do it eh :rolleyes:

but i'm still stuck on this tho :D

http://www.msfn.org/board/index.php?act=ST...t=0#entry124886

#13 User is offline   mdes 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 343
  • Joined: 07-November 03

  Posted 22 April 2004 - 05:27 AM

@yourtech: Could you NOT use "words" such as "doh", "n/m", "tho", "k";...: I cannot understand them :)

#14 User is offline   yourtech 

  • Member
  • PipPip
  • Group: Members
  • Posts: 116
  • Joined: 17-April 04

Posted 22 April 2004 - 07:03 AM

you have got to be kidding :)

#15 User is offline   mdes 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 343
  • Joined: 07-November 03

Posted 22 April 2004 - 07:10 AM

Not at all, I do really NOT understand :)

#16 User is offline   yourtech 

  • Member
  • PipPip
  • Group: Members
  • Posts: 116
  • Joined: 17-April 04

Posted 22 April 2004 - 07:15 AM

oh ok sorry :)

doh = oops (made a mistake)

k = OK (as in alright)

tho = though or although

n/m = nevermind

anything else? :rolleyes:

I don't mind even though my hand hurts :D

#17 User is offline   mdes 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 343
  • Joined: 07-November 03

  Posted 22 April 2004 - 07:24 AM

OK & Thanks. In France, we call it "writing SMS like" :)

So, do you still other question on the MapDrive.cmd usage?

#18 User is offline   yourtech 

  • Member
  • PipPip
  • Group: Members
  • Posts: 116
  • Joined: 17-April 04

Posted 22 April 2004 - 08:13 AM

No problem (I thought you were being sarcastic at first) :)

but anyway yep come to think about it i do have a question!

From my previous post:

Quote

I'm trying to accomplish this on a dual boot (xp/2K) machine :rolleyes:
(2 C:'s (each hidden from each other), 2 D:'s, and 1 E:)


Ok MapDrive.cmd worked half right...
This was my layout beforehand: (all on a single disk)

P=Partiton

P1: C:WINXP
P2: C:WIN2K
P3: D:WINXP.PROGRAMS
P4: D:WIN2K.PROGRAMS
P5: E:STORAGE

Again, both C's were hidden from each other via bootmanager

both D's were hidden from each other via

Administrative Tools>Computer Management->Disk Management

Now after running Mapdrive on an Unattended XP Install..

The Drive Leters turn out like this (under XP)

P1: C:WINXP
P3: D:WINXP.PROGRAMS <-perfect
P4: E:2K.PROGRAMS
P5 F:STORAGE

So P2: C:WIN2K is still hidden in Windows Explorer = perfect.
P3: D:\WINXP.PROGRAMS is exactly where i want it = perfect
but P3: is visible which in turn messes up where i want "Documents and Settings" to be (Mapped to P5) with the drive letter E:

Now i put all the DRIVE.x (x=drive letter) in each respective partition i want it to be (to XP):

P1: DRIVE.c
P2: DRIVE.g
P3: DRIVE.d
P4: DRIVE.f
P5: DRIVE.e

And i don't think swapping the DRIVE.g file with DRIVE.f file will accomplish anything because P2: is obviously still hidden. So theoretically it should have worked perfectly but...

Anyway i normally hide the additional partitions via Disk Management

so would there be a reg key to hide the additional ones or

any other ideas? workarounds? fixes? :D

I really need a fix for this..because doing it this way was the original reason i investigated this unnattended install method. I read that it was the best/most reliable way to remap Program Files and the Profile & Settings Dirs. Not to mention the fact that i have carpal tunnel syndrome/rsi and have to stop doing so much computer work. Even though that's what i do for a living. (All more the reason). :D

#19 User is offline   mdes 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 343
  • Joined: 07-November 03

Posted 22 April 2004 - 04:09 PM

Quote

but P3: is visible
I suppose it is P4, anot P3.

Quote

P1: DRIVE.c
P2: DRIVE.g
P3: DRIVE.d
P4: DRIVE.f
P5: DRIVE.e

And i don't think swapping the DRIVE.g file with DRIVE.f file will accomplish anything because P2: is obviously still hidden. So theoretically it should have worked perfectly but...
But what ???

Microsoft said that an "ASSIGN LETTER" (without letter) given to DISKPART will assign the next free letter to the SELECTed VOLUME: this seems to be a bug because an error is given. So, if you want to hide volume (partition), you should execute the following command before MapDrive.cmd:
DISKPART /s file.txt
with file.txt containing
SELECT VOLUME i (for your WinXP, "i" should correspond to P4 as seen with LIST VOLUME)
REMOVE
So, no letter will be assigned to the volume which doesnot have a letter.

If the above does not work, for WinXP you should do:
\$OEM$\C\DRIVE.C (for P1)
\$OEM$\D\DRIVE.D (for P3)
\$OEM$\E\DRIVE.F (for P4)
\$OEM$\F\DRIVE.E (for P5)

and for Win2K:
\$OEM$\C\DRIVE.C (for P2)
\$OEM$\D\DRIVE.F (for P3)
\$OEM$\E\DRIVE.D (for P4)
\$OEM$\F\DRIVE.E (for P5)

This post has been edited by mdes: 06 May 2004 - 10:40 PM


#20 User is offline   Dustinwmew 

  • Member
  • PipPip
  • Group: Members
  • Posts: 122
  • Joined: 11-June 04

Posted 17 June 2004 - 10:37 AM

I am haveing hard time understanding how the program works.

1. do I put a file called "the type of drive" . "the letter I like it to be" on each drive?
2. what else do I have to do to get it to work?

Share this topic:


  • 8 Pages +
  • 1
  • 2
  • 3
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy