===
batch content:
Quote
SETLOCAL ENABLEDELAYEDEXPANSION
::get fixed drives
echo list disk >listdisk.txt
diskpart /s listdisk.txt >listresult.txt
for /f "skip=8 tokens=2 delims= " %%a in (listresult.txt) do (
echo select disk %%a >selectdisk%%a.txt
echo detail disk >>selectdisk%%a.txt
diskpart /s selectdisk%%a.txt >detaildisk%%a.txt
for /f "tokens=3 skip=17" %%b in (detaildisk%%a.txt) do (
echo %%b: >>fix.txt
)
del selectdisk%%a.txt
del detaildisk%%a.txt
)
del listdisk.txt
del listresult.txt
::get CDROM and removeable drives
FOR /F "tokens=*" %%a in ('fsutil fsinfo drives ^| FIND /V ""') DO (
set dr=%%a
SET dr=!dr:~-3,3!
SET cdr=!dr:~0,1!
IF !cdr! GTR B (
FOR /F "tokens=1 delims= " %%P IN ('fsutil fsinfo drivetype !dr! ^| FIND "CD-ROM"') DO (
SET vname=%%P
SET vname=!vname:~0,2!
echo !vname! >>CDROM.txt
)
FOR /F "tokens=1 delims= " %%P IN ('fsutil fsinfo drivetype !dr! ^| FIND /i "removable"') DO (
SET vname=%%P
SET vname=!vname:~0,2!
echo !vname! >>remove.txt
)
)
)
:: ording vid
for %%a in (fix.txt CDROM.txt remove.txt) do (
if exist %%a (
for /f %%b in (%%a) do (
IF %%b neq %systemdrive% (
mountvol %%b /l >drive.txt
mountvol %%b /d
for /f %%c in (drive.txt) do (
set vid=%%c
echo !vid! >>vid.txt
)
)
)
)
)
for %%d in (C 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 %%d: neq %systemdrive% (
echo %%d >>drv.txt
)
)
if exist "fix.txt" del fix.txt
if exist "cdrom.txt" del cdrom.txt
if exist "remove.txt" del remove.txt
for /f "tokens=*" %%a in (vid.txt) do (
set /a n+=1
set _!n!=%%a
)
set n=0
for /f "tokens=*" %%i in (drv.txt) do call :lp %%i
for /f "tokens=1,2 delims= " %%a in ('findstr "\\" c.txt') do mountvol %%b: %%a
del drv.txt
del vid.txt
del drive.txt
del c.txt
exit
:lp
set /a n+=1
echo !_%n%!%1>>c.txt
===
below is original
After installing XP from USB hard disk, the drive D letter is for USB hard disk's first partition, while E F G ... is the first hard disk's second, third, fourth ... drive letter respectively. We need such drive order: C D E F drive letter belongs to the first hard disk, and G belongs to the USB hard disk.
These two files just do the job.
No prolem, its safe.
the content of drivechange.cmd
Quote
CLS
rem SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
SET USBDRIVE=
SET TAGFILE=\usbflash
FOR %%h IN (C D E F G H I J K L M N O P Q R S T U V W X Y) DO IF EXIST "%%h:%TAGFILE%" SET USBDRIVE=%%h:
echo select disk 0 >selectdisk.txt
echo detail disk >>selectdisk.txt
diskpart /s selectdisk.txt >detaildisk.txt
echo %usbdrive:~0,1% >drv.txt
for /f "tokens=3 skip=18" %%a in (detaildisk.txt) do (
set drv=%%a
echo !drv! >>drv.txt
mountvol %%a: /l >drive.txt
for /f %%b in (drive.txt) do (
set vid=%%b
echo !vid! >>vid.txt
)
)
mountvol %usbdrive% /l >drive.txt
for /f %%c in (drive.txt) do set vid=%%c
echo %vid% >>vid.txt
call c.cmd
del selectdisk.txt
del detaildisk.txt
del drive.txt
del drv.txt
del vid.txt
for /f "tokens=2 delims= " %%a in (c.txt) do mountvol %%a: /d
for /f "tokens=1,2 delims= " %%a in (c.txt) do mountvol %%b: %%a
del c.txt
EXIT
the content of c.cmd
Quote
setlocal enabledelayedexpansion
if exist c.txt del /q c.txt
for /f "tokens=*" %%a in (vid.txt) do (
set /a n+=1
set _!n!=%%a
)
set n=0
for /f "tokens=*" %%i in (drv.txt) do call :lp %%i
goto :eof
:lp
set /a n+=1
echo !_%n%!%1>>c.txt
so, we can revise undoren.cmd and add above code and c.cmd file, drive leter will rearranged corrcetly after first logon.
I hope you can optimize two files in one.
Attached File(s)
-
orderdrv2.rar (850bytes)
Number of downloads: 31
This post has been edited by victor888: 05 October 2008 - 02:37 AM



Help

Back to top










