Jump to content

Assign CD Letter


ner

Recommended Posts

I am using the below ode to try and assign the cd letter to k:

code:

echo list volume > X:\ListCD.txt

FOR /F "tokens=2,4" %%i IN ('diskpart /s X:\ListCD.txt') DO @IF /I %%j == CD_ROM SET CDROMVOL=%%i

IF DEFINED CDROMVOL echo select volume %CDROMVOL% > X:\ChangeCD.txt

IF DEFINED CDROMVOL echo assign letter=K: >> X:\ChangeCD.txt

IF DEFINED CDROMVOL diskpart /s X:\ChangeCD.txt

call Menu.cmd

this works within Virtual PC but when i boot from the cd on system it assigned the USB hard drive to K

Pc has

2 x harddrives assign c & d

2 x CD's assigned as e & f

and then USB as k?

Link to comment
Share on other sites


Maybe the "k" letter is already "busy" (assigned to the USB HD) when you run the batch.

Are we talking about Win PE 1.x (XP/2003 based) or 2.x (Vista based)? :unsure:

With version 1.x drive letters can be assigned through migrate.inf, cannot say for 2.x.

jaclaz

Link to comment
Share on other sites

That code assumes that there is only one CD drive. Launch diskpart, then issue the command "list volume" and see how many "CD_ROM" values are listed. That FOR loop will set the CDROMVOL variable to the volume number listed on the last line that contains "CD_ROM", so you may need to make some changes or try something altogether different to get your desired result.

Link to comment
Share on other sites

I am using the below ode to try and assign the cd letter to k:

code:

echo list volume > X:\ListCD.txt

FOR /F "tokens=2,4" %%i IN ('diskpart /s X:\ListCD.txt') DO @IF /I %%j == CD_ROM SET CDROMVOL=%%i

IF DEFINED CDROMVOL echo select volume %CDROMVOL% > X:\ChangeCD.txt

IF DEFINED CDROMVOL echo assign letter=K: >> X:\ChangeCD.txt

IF DEFINED CDROMVOL diskpart /s X:\ChangeCD.txt

call Menu.cmd

this works within Virtual PC but when i boot from the cd on system it assigned the USB hard drive to K

Pc has

2 x harddrives assign c & d

2 x CD's assigned as e & f

and then USB as k?

i'm not good at such complicated scripts. i just adjust templates to my needs. so can we use above script for usb flash disk in order to determine UFD letter fixed (U: for instance)

Link to comment
Share on other sites

i'm not good at such complicated scripts. i just adjust templates to my needs. so can we use above script for usb flash disk in order to determine UFD letter fixed (U: for instance)

In other words, being:

not good at such complicated scripts

you propose to "adjust" a "reported-as-not-working-template"

to my needs

:w00t:

Let's see if we can solve the problem.

@ner

HINT:

try running simply


@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
REM ********************************
REM ENTER BELOW DESIRED DRIVE LETTER
SET CDROMLETTER=K
REM ********************************

IF EXIST ChangeCD.txt DEL ChangeCD.txt

FOR /F "tokens=2,3,4" %%A IN ('ECHO List Volume ^| diskpart.exe ^| FIND "Volume" ^| FIND /v "Volume n."') DO (
Set Busy=!Busy! %%B
SET Type=%%C
SET Type=!Type:~-3!
IF !Type!.==ROM. SET CDROMVOL=!CDROMVOL! %%A&SET CDROMCOUPLE=!CDROMCOUPLE! %%A%%B
)
SET CDROMS=%CDROMVOL:~0,2%

IF "%CDROMS%"=="%CDROMVOL%" (
SET NEWCDLETTER=%CDROMLETTER%
SET VOLUME=%CDROMCOUPLE:~1,1%
SET LETTER=%CDROMCOUPLE:~2,1%
GOTO :Change_letter
)


:Choose_letter
FOR %%A IN (%CDROMCOUPLE%) DO (
SET COUPLE=%%A
SET VOLUME=!COUPLE:~0,1!
SET LETTER=!COUPLE:~1,1!
IF "!LETTER!"=="%CDROMLETTER%" GOTO :Skipped

ECHO Volume !VOLUME! is a CD/DVD ROM mounted as letter !LETTER!:
ECHO Please enter a new drive letter for Volume !VOLUME! [Press ENTER to leave current]
ECHO Already BUSY drive letters are %BUSY%
SET NEWCDLETTER=!LETTER!
SET /P NEWCDLETTER=
IF NOT "!NEWCDLETTER!"=="!LETTER!" CALL :Change_letter
)
GOTO :EOF

:Change_letter
FOR %%A IN (%BUSY%) DO (
REM IF "%NEWCDLETTER%"=="%CDROMLETTER%" GOTO :Skipped
IF "%NEWCDLETTER%"=="%%A" CLS&ECHO Letter %NEWCDLETTER%: is BUSY. &GOTO :Choose_letter
)

(
ECHO SELECT VOLUME !VOLUME!
ECHO ASSIGN LETTER=!NEWCDLETTER!:
)>>ChangeCD.txt

:Skipped
ECHO.
ECHO Volume: %VOLUME%
ECHO Current: %LETTER%:
ECHO New: %NEWCDLETTER%:
GOTO :EOF

NO guarantees of it working properly, nor of it working at all, mind you. ;)

@darksimon

The whole problem is that diskpart has not a way (or at least we didn't find one) to determine whether a drive is a USB one (or maybe the Vista version has? :unsure:)

But you can "adapt" the above "template" for using the data in the "label" column to identify correctly a (USB) Volume with a given LABEL. ;)

Cannot say what happens if you change the actual drive letter from a batch which is running from that same drive. :unsure:

jaclaz

Link to comment
Share on other sites

hello jaclaz :)

really i'm glad to meet you for your help :)

i think i solved the drive letter issue temporarly. as far as i see (if i dont misunderstand) winpe and windows xp has

different approaches to assign drive letters. that is it doesnt matter which letter is assigned to system partition at vista environment. when windows is installed and login, xp will automaticly assign letter C to sytem partition and following up partitions with following letters. if so i my partinfo.txt as below and it worked :)

=================

select disk 1

select partition 1

assign letter=U

select disk 0

clean

create partition primary size=10000

active

assign letter=P

format fs=ntfs label="SYSTEM" quick

create partition primary

assign letter=R

format fs=ntfs label="DATA" quick

exit

=================

Now my new problem is :) setup created two folder and two files ($win_...BT$ ; $win_...LS$ ntdetect.com NTLDR) at system disk root. then nothing happend :( what might be missing ? my autorun1.cmd file is below.

=================

DISKPART /s partinfo.txt

SET CDROM=%~d0

%CDROM%\WXP86\i386\winnt32.exe /syspart:P: /tempdrive:P /unattend:"%CDROM%\WXP86\i386\winnt.sif" /makelocalsource

=================

Link to comment
Share on other sites

That's perfectly "normal". :)

You used "/makelocalsource" switch.

The switch should:

1) copy locally files to $WIN_NT$.~BT and $WIN_NT$.~LS

2) copy NTDETECT.COM and NTLDR (actually a copy of SETUPLDR.BIN renamed as NTLDR) to ROOT of Active Partition

Then "nothing happens", sure nothing will happen until you re-boot, this time from the hard disk. ;)

Do check if a migrate.inf file has been created in $WIN_NT$.~BT, though.

jaclaz

Edited by jaclaz
Link to comment
Share on other sites

hello jaclaz :)

i'm smiling but inside i wanna cry :( after the file are created on the HDD i checked the migrate.inf file inside the $WIN_NT$.~BT and $WIN_NT$.~LS folders. But there wasnt. but the worse is when i restart the virtual machine, the text phase begins but after some changing lines it says "setup is starting windows" and then it gives BSOD error numbered 0x000007B :(

i am seraching a solution for BSOD error and then i will be able to go on...

Link to comment
Share on other sites

hello jaclaz :)

i'm smiling but inside i wanna cry :( after the file are created on the HDD i checked the migrate.inf file inside the $WIN_NT$.~BT and $WIN_NT$.~LS folders. But there wasnt. but the worse is when i restart the virtual machine, the text phase begins but after some changing lines it says "setup is starting windows" and then it gives BSOD error numbered 0x000007B :(

i am seraching a solution for BSOD error and then i will be able to go on...

0x000007B means you are missing appropriate MASS STORAGE DRIVERS (which VM are you using?)

Did you use a "real" hard disk (which BUS it uses?) or an hard disk image (which format was it?).

The idea was to ADD (if not present) a migrate.inf file, generated by mkmigrateinf.cmd:

http://www.911cd.net/forums//index.php?showtopic=19663

to pre-assign the letter, or , if present to MODIFY it to the same effect.

jaclaz

Link to comment
Share on other sites

hi jaclaz :)

you wont believe but i think i solved the letter assignment issue :) here'a what i did:

i added install.cmd at the usb root. below is my install.cmd

==================================

SET CDROM=%~d0

%CDROM%\WXP86\i386\winnt32.exe /syspart:C: /tempdrive:C /unattend:"%CDROM%\WXP86\i386\winnt.sif" /makelocalsource

==================================

and then i unmounted the winpe.wim image and added the partinfo.txt, start.cmd files under the .\mount folder. below is my partinfo.txt and start.cmd files

=======partinfo.txt===============

select disk 1

select partition 1

assign letter=U

select disk 0

clean

create partition primary size=5000

active

assign letter=C

format fs=ntfs label="SYSTEM" quick

create partition primary

assign letter=D

format fs=ntfs label="DATA" quick

exit

==========start.cmd============

@echo off & color 5b & title wellcome to my special USB Flash Disk :)

:start

cls

set /p userinp=Press (1) for Install or (2) for Quit:

set userinp=%userinp:~0,1%

if "%userinp%"=="1" goto Install

if "%userinp%"=="2" goto Quit

:Install

DISKPART /s partinfo.txt

U:\install.cmd

goto end

:Quit

exit

goto end

:end

pause>nul

======================

lastly add "\start.cmd" lines to startnet.cmd file which resides under mount\windows\system32. then i mounted the image file (winpe.wim) and added it under the usbroot/sources folder by renaming as boot.wim.

when boot from usb, a windows occurs and asks if i want to install or not. in order to install, i press 1 and enter. then it applies the partinfo.txt as i want and assigns the letter C to HDD active partition. because i do all these commans from X:\.

then it calls the install.cmd file and windows installation begins with the correct partition letters :)

C:\system

D:\data

U:\winpe UDF

E:\DVD-ROM

i feel good... (somehow sometimes it gives me error saying script file couldnt read blah blah... but when get this error i go to x:\ and call start.cmd from there. i think it's not important error.)

but the same BSOD continues :( i'm using vmware6 as virtual machine and winpe 2.0 as image file. once i added scsi drivers from a floppy image on the virtual machine but the result is same. i havent tried it on a real machine. but i believe it will be allright. i still continue to work. :) and of course by your help

meanwhile i thank you again for your effort to help me :)

post-58042-1227995477_thumb.png

Edited by darksimoon
Link to comment
Share on other sites

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...