Jump to content

Drive letters changing between reboots


Recommended Posts

I have ran into a real problem. :realmad:

On my new computer when I do an unattended install, it seems that the drive letters are changing across reboots. :wacko: In GUI setup, the DVD drive is H:, but when RegOnceEX runs, it gets reordered to D:, so because RegOnceEX is looking to H:, it fails because it cannot find the scripts. The computer does have a USB card reader installed.

What I don't understand is why the 4 drives on the USB card reader is showing up as D-G with the DVD as H during GUI setup when during first login it reorders with the DVD being D and the card reader being E-H. :huh:

Any ideas as to why this is happening and how to fix it?

Link to comment
Share on other sites


Unfortunatly, "who knows what evil lurks in the hearts of men..." and how exactly Windows decides it's drive letter assignments.

It's a hassle and I don't know if it'll work with the card reader or not, but you can use diskpart with a script to assign all the drive letters the way you want them.

Or, use a variable like %CDROM% in your runonce lines, but instead of determining the DVD's drive letter when you build the RunOnceEx, determine it when it executes.

Your RunOnceEx lines will have "%CDROM%\Apps\....\setup.exe", but the very first thing, before any installs begin, have it run the script that selects the DVD's drive letter and assigns it to %CDROM%. This should work for you. So, even though the drive letters change, the %CDROM% variable isn't pupulated until first logon.

Link to comment
Share on other sites

Unfortunatly, "who knows what evil lurks in the hearts of men..." and how exactly Windows decides it's drive letter assignments.

My question is why does it reorder the drive letters during the install?

It's a hassle and I don't know if it'll work with the card reader or not, but you can use diskpart with a script to assign all the drive letters the way you want them.
This disk is to be used with multiple computers, each with a different config. So unless diskpart can analyze the drive map and make some decisions, it will be useless.
Or, use a variable like %CDROM% in your runonce lines, but instead of determining the DVD's drive letter when you build the RunOnceEx, determine it when it executes.

Your RunOnceEx lines will have "%CDROM%\Apps\....\setup.exe", but the very first thing, before any installs begin, have it run the script that selects the DVD's drive letter and assigns it to %CDROM%. This should work for you. So, even though the drive letters change, the %CDROM% variable isn't pupulated until first logon.

AFAIK, you cannot place a %CDROM% in a string to be added to the registry because CMD.exe will try to interpret it when it's encountered.

But, that does give me an idea on how to get around this...Use my SYSTEM-PREPARE.CMD script from RunOnceEX to determine the current drive letter and then stuff the RegOnceEX keys with the correct data. I would have to use placeholders to hold each entry so it appears on the list. This is going to be *VERY* dependent on RegOnceEX's behavior.

We know that RegOnceEX reads all the reg data at once because it presents the list of items to perform. But, that's just titles though. Does it also read the execution data at the same time and store it in a buffer, or does it read it from the registery one line at a time? And if this does work, then hope to God that Microsoft doesn't change it because then we will be screwed.

Link to comment
Share on other sites

Well that method didn't work. It seems that RegOnceEX reads all the data in the registery at once and then stores it in a buffer, so subsequent modifications of the registery doesn't have an effect. I still have a couple of ideas rattling around inside my head on how to resolve this.

An idea that I have it using a VBS or AutoIT script to determine what the CDROM drive is and then call the scripts in question according to what command line parameters were given. Something like this:

CDEXEC.exe x INSTALL-RC.CMD

Where x is either 0 or 1 which indicates if the execution should be forked or not. It looks for the script in the default scripts directory on the CDROM drive, and if it's not found, it shows an error.

I didn't want to have to do it this way, but now I have no choice in the matter.

Link to comment
Share on other sites

he gave you a perfectly good way to accomplish what you want.

this is my cmdlines.txt:

[COMMANDS]
"RunOnceEx.cmd"

this is first line in my RunOnceEx.cmd:

FOR %%i IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%i:\2Fast_XP.nfo SET CDROM=%%i:

in my RunOnceEx.cmd i then run them like so:

SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx

REG ADD %KEY% /V TITLE /D "Installing Applications..." /f
REG ADD %KEY%\005 /VE /D ".Net Framework 2.0" /f
REG ADD %KEY%\005 /V 1 /D "%cdrom%\Install\Net20\install.exe /q" /f

it works like a charm. when using a forum you should perhaps ignore what you think you know and be more open to suggestion.

Edited by ophiel
Link to comment
Share on other sites

he gave you a perfectly good way to accomplish what you want.

this is my cmdlines.txt:

[COMMANDS]
"RunOnceEx.cmd"

this is first line in my RunOnceEx.cmd:

FOR %%i IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%i:\2Fast_XP.nfo SET CDROM=%%i:

in my RunOnceEx.cmd i then run them like so:

SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx

REG ADD %KEY% /V TITLE /D "Installing Applications..." /f
REG ADD %KEY%\005 /VE /D ".Net Framework 2.0" /f
REG ADD %KEY%\005 /V 1 /D "%cdrom%\Install\Net20\install.exe /q" /f

I am allready doing this...well something similar since the original code was written along time ago (see below).

The problem is that Windows is changing the drive letter mapping across reboots from GUI setup and first login.

In GUI setup:

C: HD
D: card slot 1
E: card slot 2
F: card slot 3
G: card slot 4
H: DVD

After the reboot to first login:

C: HD
D: DVD
E: card slot 1
F: card slot 2
G: card slot 3
H: card slot 4

As you can see, the driver letter map changed after the reboot. So when RunOnceEX executes at first login, it's looking for the files on drive H when they have been moved to drive D.

Here's what I'm using:

cmdlines.txt

[Commands]
"WINSETUP.CMD"

WINSETUP.CMD

@ECHO OFF

REM Check the command line argument. If nothing is given, then we are going to do a
REM live install from the DVD-ROM. If TST is given, then we are in the test
REM environment on the harddisk and the base path is different.

IF /I "%1"=="" GOTO :START
IF /I "%1"=="TST" GOTO :TEST
GOTO :ERROR

REM This is the DVD-ROM Installation
:START
REM Hide the command window
CMDOW @ /HID

REM Find our CD-ROM Drive and set the evnironment variable
SET CHECKFILE=win51ip.SP2
IF EXIST C:\%CHECKFILE% SET CDROM=C:
IF EXIST D:\%CHECKFILE% SET CDROM=D:
IF EXIST E:\%CHECKFILE% SET CDROM=E:
IF EXIST F:\%CHECKFILE% SET CDROM=F:
IF EXIST G:\%CHECKFILE% SET CDROM=G:
IF EXIST H:\%CHECKFILE% SET CDROM=H:
IF EXIST I:\%CHECKFILE% SET CDROM=I:
IF EXIST J:\%CHECKFILE% SET CDROM=J:
IF EXIST K:\%CHECKFILE% SET CDROM=K:
IF EXIST L:\%CHECKFILE% SET CDROM=L:
IF EXIST M:\%CHECKFILE% SET CDROM=M:
IF EXIST N:\%CHECKFILE% SET CDROM=N:
IF EXIST O:\%CHECKFILE% SET CDROM=O:
IF EXIST P:\%CHECKFILE% SET CDROM=P:
IF EXIST Q:\%CHECKFILE% SET CDROM=Q:
IF EXIST R:\%CHECKFILE% SET CDROM=R:
IF EXIST S:\%CHECKFILE% SET CDROM=S:
IF EXIST T:\%CHECKFILE% SET CDROM=T:
IF EXIST U:\%CHECKFILE% SET CDROM=U:
IF EXIST V:\%CHECKFILE% SET CDROM=V:
IF EXIST W:\%CHECKFILE% SET CDROM=W:
IF EXIST X:\%CHECKFILE% SET CDROM=X:
IF EXIST Y:\%CHECKFILE% SET CDROM=Y:
IF EXIST Z:\%CHECKFILE% SET CDROM=Z:

REM Set our base DIR and call the main system script.
SET BASEDIR=%CDROM%\INSTALL
START /WAIT %SYSTEMROOT%\System32\CMD.EXE /C %BASEDIR%\SCRIPTS\SYSTEM-INSTALL.CMD %CDROM% %BASEDIR%
GOTO :EOF

REM This is for our test environment
:TEST
@ECHO ON
SET CDROM=E:
SET BASEDIR=%CDROM%\Deployment\CDROM\INSTALL
START /WAIT %SYSTEMROOT%\System32\CMD.EXE /C %BASEDIR%\SCRIPTS\SYSTEM-INSTALL.CMD %CDROM% %BASEDIR%
GOTO :EOF

REM This is only called if there is a command line argument error
:ERROR
ECHO Command Line Error
ECHO Valid Options are nothing and TST for install and test
GOTO :EOF

SYSTEM-INSTALL.CMD

@ECHO OFF
CMDOW @ /HID



REM Get Our Command Line Parameters
SET CDROM=%1
SET BASEDIR=%2

REM Setup Our Environment
SET SCRIPTSDIR=%BASEDIR%\SCRIPTS
SET TOOLSDIR=%BASEDIR%\TOOLS
SET TEMPDIR=%SYSTEMDRIVE%\TMP
SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEX



REM Make sure that our temp directory is present
IF /I NOT EXIST %TEMPDIR% MKDIR %TEMPDIR%

REM Set The Working Directory
CHDIR %SCRIPTSDIR%

REM Install Tweaks
START /WAIT %SYSTEMROOT%\System32\CMD.EXE /C %SCRIPTSDIR%\TWEAK-SYSTEM.CMD %BASEDIR%
START /WAIT %SYSTEMROOT%\System32\CMD.EXE /C %SCRIPTSDIR%\TWEAK-REGISTRY.CMD %BASEDIR%
START /WAIT %SYSTEMROOT%\System32\CMD.EXE /C %SCRIPTSDIR%\TWEAK-POWER.CMD %BASEDIR%
START /WAIT %SYSTEMROOT%\System32\CMD.EXE /C %SCRIPTSDIR%\TWEAK-FILESYSTEM.CMD %BASEDIR%

REM RegOnceEX

REM Prepare the Install **MUST BE FIRST**
REG ADD %KEY% /V TITLE /D "Installing Software" /f
REG ADD %KEY%\001 /VE /D "Preparing Installation..." /f
rem REG ADD %KEY%\001 /V 1 /D "%SYSTEMROOT%\System32\CMD.EXE /C %SCRIPTSDIR%\SYSTEM-PREPARE.CMD %BASEDIR%" /f
REG ADD %KEY%\001 /V 1 /D "%SYSTEMROOT%\System32\CMD.EXE /C %TEMPDIR%\SYSTEM-PREPARE.CMD %BASEDIR%" /f
REG ADD %KEY%\002 /VE /D "Set Video Resolution" /f
REG ADD %KEY%\002 /V /1 /D "%SYSTEMROOT%\System32\CMD.EXE /C %SCRIPTSDIR%\SYSTEM-GUIKILLER.CMD %BASEDIR%"
REG ADD %KEY%\003 /VE /D "Fork Image Rotator" /f
REG ADD %KEY%\003 /V /1 /D "%SYSTEMROOT%\System32\CMD.EXE /C START CMD.EXE /C %SCRIPTSDIR%\SYSTEM-IMAGEROTATE.CMD %BASEDIR%"
rem REG ADD %KEY%\004 /VE /D "Set Background Image" /f
rem REG ADD %KEY%\004 /V /1 /D "%SYSTEMROOT%\System32\CMD.EXE /C START CMD.EXE /C %SCRIPTSDIR%\SYSTEM-SETWALLPAPER.CMD %BASEDIR%"

REM Install CD Files and Recovery Console
REG ADD %KEY%\100 /VE /D "Installing Windows CD-ROM" /f
REG ADD %KEY%\100 /V 1 /D "%SYSTEMROOT%\System32\CMD.EXE /C %SCRIPTSDIR%\INSTALL-CDROM.CMD %CDROM% %BASEDIR%" /f
REG ADD %KEY%\101 /VE /D "Installing Recovery Console" /f
REG ADD %KEY%\101 /V 1 /D "%SYSTEMROOT%\System32\CMD.EXE /C %SCRIPTSDIR%\INSTALL-RC.CMD %CDROM% %BASEDIR%" /f

REM Install Software
SET SEQUENCE=110
IF /I EXIST %SCRIPTSDIR%/MAIN-DRIVER.XML CALL :INSTALLDRIVER
SET SEQUENCE=111
IF /I EXIST %SCRIPTSDIR%/MAIN-HOTFIX.XML CALL :INSTALLHOTFIX
SET SEQUENCE=112
IF /I EXIST %SCRIPTSDIR%/MAIN-FONTS.XML CALL :INSTALLFONT
SET SEQUENCE=113
IF /I EXIST %SCRIPTSDIR%/MAIN-MEDIA.XML CALL :INSTALLMEDIA
SET SEQUENCE=114
IF /I EXIST %SCRIPTSDIR%/MAIN-SOFTWARE.XML CALL :INSTALLSOFTWARE

REM Copy over additional files
REG ADD %KEY%\900 /VE /D "Installing Additional Files" /f
REG ADD %KEY%\900 /V 1 /D "%SYSTEMROOT%\System32\CMD.EXE /C %SCRIPTSDIR%\INSTALL-FILES.CMD %BASEDIR%" /f

REM Install Scripts
REG ADD %KEY%\901 /VE /D "Installing Scripts" /f
REG ADD %KEY%\901 /V 1 /D "%SYSTEMROOT%\System32\CMD.EXE /C %SCRIPTSDIR%\INSTALL-SCRIPTS.CMD %BASEDIR%" /f

REM Set File Permissions
REG ADD %KEY%\902 /VE /D "Set File Permissions" /f
REG ADD %KEY%\902 /V 1 /D "%SYSTEMROOT%\System32\CMD.EXE /C %SCRIPTSDIR%\SYSTEM-PERMISSIONS.CMD %BASEDIR%" /f

REM Sequence 990-999 **MUST BE LAST**
REM Cleanup and Reboot
REG ADD %KEY%\994 /VE /D "Cleaning Up" /f
REG ADD %KEY%\994 /V 1 /D "%SYSTEMROOT%\System32\CMD.EXE /C %SCRIPTSDIR%\SYSTEM-CLEANUP.CMD %BASEDIR%" /f
REG ADD %KEY%\995 /VE /D "Defragmenting System Harddisk" /f
REG ADD %KEY%\995 /V 1 /D "%SYSTEMROOT%\System32\CMD.EXE /C %SCRIPTSDIR%\SYSTEM-DEFRAG.CMD" /f
REG ADD %KEY%\996 /VE /D "Change Registration Information" /f
REG ADD %KEY%\996 /V 1 /D "%TOOLSDIR%\MISC\CHGREG.EXE" /f
REG ADD %KEY%\997 /VE /D "Set Desktop Image"
REG ADD %KEY%\997 /V /1 /D "%SYSTEMROOT%\System32\CMD.EXE /C %SCRIPTSDIR%\SYSTEM-SETWALLPAPER.CMD" /f
REG ADD %KEY%\998 /VE /D "Fork Detached Program" /f
REG ADD %KEY%\998 /V /1 /D "%SYSTEMROOT%\System32\CMD.EXE /C START CMD.EXE /C %SCRIPTSDIR%\SYSTEM-DETACHED.CMD %BASEDIR%"
REG ADD %KEY%\999 /VE /D "Rebooting..." /f
REG ADD %KEY%\999 /V 1 /D "%SYSTEMROOT%\System32\CMD.EXE /C %SCRIPTSDIR%\SYSTEM-REBOOT.CMD" /f
GOTO :EOF



:INSTALLDRIVER
REG ADD %KEY%\%SEQUENCE% /VE /D "Installing Drivers" /f
REG ADD %KEY%\%SEQUENCE% /V 1 /D "%SYSTEMROOT%\System32\CMD.EXE /C %SCRIPTSDIR%\INSTALL-DRIVER.CMD %BASEDIR%" /f
GOTO :EOF

:INSTALLHOTFIX
REG ADD %KEY%\%SEQUENCE% /VE /D "Installing Hotfixes" /f
REG ADD %KEY%\%SEQUENCE% /V 1 /D "%SYSTEMROOT%\System32\CMD.EXE /C %SCRIPTSDIR%\INSTALL-HOTFIX.CMD %BASEDIR%" /f
GOTO :EOF

:INSTALLFONT
REG ADD %KEY%\%SEQUENCE% /VE /D "Installing Fonts" /f
REG ADD %KEY%\%SEQUENCE% /V 1 /D "%SYSTEMROOT%\System32\CMD.EXE /C %SCRIPTSDIR%\INSTALL-FONTS.CMD %BASEDIR%" /f
GOTO :EOF

:INSTALLMEDIA
REG ADD %KEY%\%SEQUENCE% /VE /D "Installing Media" /f
REG ADD %KEY%\%SEQUENCE% /V 1 /D "%SYSTEMROOT%\System32\CMD.EXE /C %SCRIPTSDIR%\INSTALL-MEDIA.CMD %BASEDIR%" /f
GOTO :EOF

:INSTALLSOFTWARE
REG ADD %KEY%\%SEQUENCE% /VE /D "Installing Software" /f
REG ADD %KEY%\%SEQUENCE% /V 1 /D "%SYSTEMROOT%\System32\CMD.EXE /C %SCRIPTSDIR%\INSTALL-SOFTWARE.CMD %BASEDIR%" /f
GOTO :EOF


REM RunOnceEX install template
:INSTALL
REG ADD %KEY%\%SEQUENCE% /VE /D "Installing " /f
REG ADD %KEY%\%SEQUENCE% /V 1 /D "%SYSTEMROOT%\System32\CMD.EXE /C %SCRIPTSDIR%\INSTALL-.CMD %BASEDIR%" /f
GOTO :EOF

And one of the install files:

INSTALL-HOTFIX.CMD

@ECHO OFF
CMDOW @ /HID

REM Set Variables
SET NAME=HOTFIX



REM Get Command Line Parameters
SET BASEDIR=%1



REM Setup Our Environment
SET XPLODEDIR=%BASEDIR%\TOOLS\XPLODE
SET SCRIPTSDIR=%BASEDIR%\SCRIPTS
SET LOADFILE=%SCRIPTSDIR%\MAIN-%NAME%.XML


REM Check for the XML file that XPlode needs to see
IF /I NOT EXIST %LOADFILE% GOTO :EOF

REM Run Installation
START /WAIT %XPLODEDIR%\XPLODE.EXE /xml:"%LOADFILE%" /log:"%SYSTEMROOT%\XPlode.log"

REM Cleanup
SYNC.EXE

it works like a charm. when using a forum you should perhaps ignore what you think you know and be more open to suggestion.

Um...I am open to suggestions, which is why I posted here in the first place. Not to sound rude or anything, but read the original post and you will see what I'm talking about. :whistle:

Link to comment
Share on other sites

At GUIRunOnce I am installing ActivePerl then I am running among other things a rather old Perl script that changes the CD drive letter to R:

Upon reboot my cdrom is set to R :)

Since my source is in %cdrom%\setup\wxpsp2 I patch my registry so that windows knows where to find the files:

reg.exe ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup" /v "SourcePath" /t REG_SZ /d R:\SETUP\WXPSP2\ /F
reg.exe ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup" /v "ServicePackSourcePath" /t REG_SZ /d R:\SETUP\WXPSP2 /F
reg.exe ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "SourcePath" /t REG_SZ /d R:\SETUP\WXPSP2\i386 /F

You could write something similar in VB if you don't want to use Perl.

Hope this helps

CF

Link to comment
Share on other sites

heh, sorry for being a dick, but it seemed like you were ignoring good advice.

the code you posted should work flawlessly, it's very similar to what i do.

did you try logging the output of your scripts to find any errors?

(i.e. winsetup.cmd >>log.txt)

Link to comment
Share on other sites

The problem is not really in the script. The registery is loaded with the correct values. I actually get an error from RegOnceEX because it says that "H:\INSTALL\TOOLS\MISC/CHGREG.EXE" cannot be found. That's how I know what was programmed into the registery. Furthermore, I'm able to do <CTRL>-<ALT>-<DEL> to bring up task manager and open up Explorer. The system shows that the DVD drive is D: at that point. Furthermore, when I open RegEdit and look at the remaining data in HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnceEX, it shows everything pointing to H:.

I think that I might have come up with something though. I'll let you know how it works.

Link to comment
Share on other sites

  • 1 month later...

I think everyone has this problem, but many people might still not understand:

Like TS said..

On a new PC, a new harddisk (1 harddisk!) and DVD drive (1 DVD drive!) without partitions, I insert my unAttended CD run WIndows Setup, create 2 partitions and install windows on the first one.

After install has finished completely, I check My Computer and I see this:

C:\ = hard drive

D:\ = CD/DVD drive

E:\ = hard drive, 2nd partition.

This is not what I want... I want the harddisk partitions to have the first letters.. then CD/DVD drive!

So how can I modify Windows Setup not to give the CD/DVD drive(s!, or card slots) priority when creating new partitions?

Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...