victor888 Posted October 12, 2008 Posted October 12, 2008 (edited) Thanks to Jaclaz for his help.Temp files removed, running speed improved.The problem of when booting pe from usb hard disk sometimes usb hard disk get number DISK 0 and internal hd get disk 1 was solved.This batch file's former content view this: http://www.msfn.org/board/index.php?showtopic=123929It is used under NT system such as win2k, PE, winxp and win2003. I haven't tested it under vista.Do run it on system drive of virtual drive. Do remember to close all programs and files/folders stored on non-system-drive because during the running period it will unmount drives except system drive and virtual drives. It is ideal to run it on newly installed system i.e. installing xp from pe, direct installing xp by using usb stick or usb hard disk. For using usb_multiboot_10.cmd I think there is no need to revise migrate.inf to fix usb stick drive letter. Just run this batch as your need.For non-Englisgh system, just change "removable" in this line:::created by VICTOR888::ordering drive letters by drive type::ordered drive letters are assigned to fixed disk, cdrom, usb hard disk and usb stickSETLOCAL ENABLEEXTENSIONSSETLOCAL ENABLEDELAYEDEXPANSION::get usbdisk amountset /a usbdiskam=0for /f %%a in ('reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Disk\Enum /s ^| find "USBSTOR"') do ( set /a usbdiskam=!usbdiskam!+1)::get removable usb disk amount and their drive lettersset /a remusbam=0if %usbdiskam% GTR 0 ( FOR /F "tokens=*" %%a in ('fsutil fsinfo drives ^| FIND /V ""') DO ( set dr=%%a SET dr=!dr:~-5,1! IF !dr! GTR B ( FOR /F "tokens=1 delims= " %%P IN ('fsutil fsinfo drivetype !dr!: ^| FIND "re"') DO ( set /a remusbam=!remusbam!+1 SET vname=%%P SET vname=!vname:~0,1! call set remusb=%%remusb%% %%vname%% ) ) ) )::get fixed usb disk amountif %usbdiskam% GTR 0 ( set /a fixedusbam=%usbdiskam%-%remusbam%) else ( set /a fixedusbam=0)::get total hard disks amountset /a totalhdam=0for /f "skip=9 tokens=2" %%a in ('echo list disk ^| diskpart.exe') do ( set /a totalhdam=!totalhdam!+1)::get innternal fixed hard disk amountset /a fixedhdam=%totalhdam%-%fixedusbam%::get internal hard disk drive letters and fixed usb drive lettersif %fixedusbam% equ 0 ( for /f "skip=9 tokens=2" %%a in ('echo list disk ^| diskpart.exe') do ( echo select disk %%a >selectdisk%%a.txt echo detail disk >>selectdisk%%a.txt for /f "tokens=3 skip=17" %%b in ('diskpart /s selectdisk%%a.txt') do ( set dr=%%b call set fixdrv=%%fixdrv%% %%dr%% ) del selectdisk%%a.txt ) ) else ( for /f "tokens=1 delims=\" %%a in ('reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Disk\Enum /v 0 ^| find "REG_SZ"') do set hd=%%a if "%hd:~-7%" neq "USBSTOR" ( for /f "skip=9 tokens=2" %%a in ('echo list disk ^| diskpart.exe') do ( set /a counter=!counter!+1 echo select disk %%a >selectdisk%%a.txt echo detail disk >>selectdisk%%a.txt if !counter! LEQ %fixedhdam% ( for /f "tokens=3 skip=17" %%b in ('diskpart /s selectdisk%%a.txt') do ( set dr=%%b call set fixdrv=%%fixdrv%% %%dr%% del selectdisk%%a.txt ) ) else ( for /f "tokens=3 skip=17" %%b in ('diskpart /s selectdisk%%a.txt') do ( set dr=%%b call set hdusb=%%hdusb%% %%dr%% del selectdisk%%a.txt ) ) ) ) else ( echo select disk 0 >selectdisk0.txt echo detail disk >>selectdisk0.txt for /f "tokens=3 skip=17" %%b in ('diskpart /s selectdisk0.txt') do ( set dr=%%b call set hdusb=%%hdusb%% %%dr%% del selectdisk0.txt ) for /f "skip=10 tokens=2" %%a in ('echo list disk ^| diskpart.exe') do ( set /a counter=!counter!+1 echo select disk %%a >selectdisk%%a.txt echo detail disk >>selectdisk%%a.txt if !counter! LEQ %fixedhdam% ( for /f "tokens=3 skip=17" %%b in ('diskpart /s selectdisk%%a.txt') do ( set dr=%%b call set fixdrv=%%fixdrv%% %%dr%% del selectdisk%%a.txt ) ) else ( for /f "tokens=3 skip=17" %%b in ('diskpart /s selectdisk%%a.txt') do ( set dr=%%b call set hdusb=%%hdusb%% %%dr%% del selectdisk%%a.txt ) ) ) ))::get all drive letters except AFOR /F "tokens=*" %%b in ('fsutil fsinfo drives ^| FIND /V ""') DO ( set dr=%%b SET dr=!dr:~-5,1! IF !dr! GTR B call set alldrv=%%alldrv%% %%dr%%)::get drive letters with mount pointFOR /F %%a in ('mountvol ^| findstr :\') do ( set dr=%%a set dr=!dr:~0,1! IF !dr! GTR A call set mountdrv=%%mountdrv%% %%dr:~0,1%% ))::get virtual drives created by virtual CD soft, command subst, net use and ram disk etc.set virdrv=%alldrv%for %%a in (%mountdrv%) do call set virdrv=%%virdrv:%%a=%%set virdrv=%virdrv% %systemdrive:~0,1%::get CDROM drive lettersFOR /F "tokens=*" %%a in ('fsutil fsinfo drives ^| FIND /V ""') DO ( set dr=%%a SET dr=!dr:~-5,1! IF !dr! GTR A ( FOR /F "tokens=1 delims= " %%P IN ('fsutil fsinfo drivetype !dr!: ^| FIND "CD-ROM"') DO ( SET vname=%%P SET vname=!vname:~0,1! for /f %%b in ('mountvol !vname!: /l ^| find "\\"') do call set cdrom=%%cdrom%% %%vname%% ) ))::ordering drive letters by internal fixed hard disk, cdrom, hard usb disk and removalbe usbdiskset neworder=%fixdrv% %cdrom% %hdusb% %remusb%set fulldrv=CDEFGHIJKLMNOPQRSTUVWXYZfor %%a in (%virdrv%) do call set fulldrv=%%fulldrv:%%a=%%:: get ordered vidset /a n=0for %%a in (%neworder%) do ( if %%a neq %systemdrive:~0,1% ( for /f %%b in ('mountvol %%a: /l') do ( mountvol %%a: /dcall echo %%b %%fulldrv:~!n!,1%%: >>c.txt set /a n+=1 ) ))for /f "tokens=1,2 delims= " %%a in (c.txt) do mountvol %%b %%adel c.txtorderdrv3.rar Edited November 1, 2008 by victor888
jaclaz Posted October 13, 2008 Posted October 13, 2008 (edited) Thanks to Jaclaz for his help.You are welcome. I changed the board tags from CODE to CODEBOX as to make the thread more readable.At first sight you still have a number of temporary text files:remusb.txtselectdisk%%a.txtfixdrv.txthdusb.txtalldrv.txtmountdrv.txttempfile.txttempfile2.txtvirdrv.txtCDROM.txt remusb.txtvid.txtdrv.txtc.txtI'll see, as soon as I have some spare time, if I can find some ways to remove (or minimize) the need for temp files.jaclazP.S.: Maybe this approach may work?Just an example, first "separate" Removable drives from Fixed .....:@ECHO OFFSETLOCAL ENABLEEXTENSIONSSETLOCAL ENABLEDELAYEDEXPANSIONFOR %%A IN ( A B C D E F G H I J K L M N O P Q R S T U V Z) DO (FOR /F "tokens=1,2,3,4 delims= " %%B IN ('REG QUERY HKLM\SYSTEM\MountedDevices\ /V \DosDevices\%%A: 2^>^&1^|FIND "REG_BINARY"') DO (REM ECHO %%A %%B %%C %%DCALL :Drivetype %%A %%D))SET First8SET FIXEDSET REMOVABLEPAUSEGOTO :EOF:DrivetypeSET DRIVE_%1=%2CALL SET First8_%1=!DRIVE_%1:~0,8!IF !First8_%1!.==5C003F00. (SET REMOVABLE=%REMOVABLE%%1:,) ELSE (SET FIXED=%FIXED%%1:,)GOTO :EOF Edited October 13, 2008 by jaclaz
victor888 Posted October 13, 2008 Author Posted October 13, 2008 I think registry site mounteddevice is not reliable because when a removable device unpluged the drive letter and mount point still exist.
jaclaz Posted October 14, 2008 Posted October 14, 2008 I think registry site mounteddevice is not reliable because when a removable device unpluged the drive letter and mount point still exist.Yes, you are right, but it may help in "limiting" the range, like a pre-check.Take it as a "heuristic" approach, , drive letters that won't be found in the Registry were never been assigned. jaclaz
victor888 Posted October 14, 2008 Author Posted October 14, 2008 That is true.hope your optimized version.
bobob Posted October 15, 2008 Posted October 15, 2008 I downloaded a slimmed down version of XP (XP Performance Edition). When I browse to this folder, I get the error that WINNT32.EXE is not found and that certain options should not be used when slimming XP down with nLite.I do not know if the person who made this slimmed down version did just that, but is it somehow possible to get things working? I have a bootable iso image and a usb stick. Somehow this should be able to work, right?
victor888 Posted October 15, 2008 Author Posted October 15, 2008 as long has the command fsutil, mountvol, diskpart and findstr exist, the batch does work.
jaclaz Posted October 16, 2008 Posted October 16, 2008 (edited) I downloaded a slimmed down version of XP (XP Performance Edition). When I browse to this folder, I get the error that WINNT32.EXE is not found and that certain options should not be used when slimming XP down with nLite.Sure, and you expect to get help and support for a WAREZ release? Check Rules:http://www.msfn.org/board/Forum-Rules-Updated-Re-t18408.htmlI do not know if the person who made this slimmed down version did just that, but is it somehow possible to get things working? I have a bootable iso image and a usb stick. Somehow this should be able to work, right?I guess both you and the "the person who made this slimmed version" have failed to read the FAQ's, that version has probably "Operating System Options-->Manual Install and Upgrade for removal" REMOVED. jaclaz Edited October 16, 2008 by jaclaz
bobob Posted October 16, 2008 Posted October 16, 2008 Sure, and you expect to get help and support for a WAREZ release?I have a original XP cd-rom (which I don't use more on my Vista desktop). I don't understand why this would be illegal (you can alter a product you have legally bought). I thought that is why programs like nLite are out there. (BTW "the other person" is actually another person)
jaclaz Posted October 16, 2008 Posted October 16, 2008 I have a original XP cd-rom (which I don't use more on my Vista desktop). I don't understand why this would be illegal (you can alter a product you have legally bought). I thought that is why programs like nLite are out there. (BTW "the other person" is actually another person)If you build out of your original XP CD, unless you used nlite too aggressively, removing thing you should have not, it will work.You mentioned downloading "XP Performance Edition", which is a known WAREZ release.jaclaz
jaclaz Posted October 20, 2008 Posted October 20, 2008 Not yet had enough time to go through it, however, it seems to me that you forget the possibility of a SCSI drive and of a Removable SCSI drive.Get the the Perisoft minifile and miniram drivers and try it: http://www.perisoft.net/miniport/index.htmjaclaz
victor888 Posted October 20, 2008 Author Posted October 20, 2008 (edited) SCSI drive is concerned too. Edited October 21, 2008 by victor888
jaclaz Posted October 22, 2008 Posted October 22, 2008 (edited) I had a somewhat deeper look at the batch.It is a GOOD idea and the code is OK BUT, in a nutshell, I do not like it. I mean, I feel like it is overly complex, and it is possible that it won't work on some localized versions. (changing the "Removable" to "mov" should cover a number of European ones)I did a couple of check and some temp files can be made unneeded.Still, I could not find a way to manage diskpart without a temp file.While researching about it, I found something I had never seen (or better never paid attention to) that may be a better approach:WMIC (Windows Management Instrumentation Command):http://www.ss64.com/nt/wmic.htmlhttp://www.robvanderwoude.com/wmic.htmlhttp://www.robvanderwoude.com/wmigen.htmlhttp://www.robvanderwoude.com/arrays_bat.htmlMaybe this could be a "slimmer" approach. Check the attached example.jaclaztestwmic.zip Edited October 22, 2008 by jaclaz
victor888 Posted October 22, 2008 Author Posted October 22, 2008 (edited) I need your optimized version.I think of using wmic but do not study it.Your sample is really very good. WMIC command is too powerful. Edited October 22, 2008 by victor888
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now