
congnt92
Content Type
Profiles
Forums
Events
Posts posted by congnt92
-
-
Using EFI system partition GUID C12A7328-F81F-11D2-BA4B-00A0C93EC93B to detect EFI partition is a safety way but I do not know which command to get GUID of partition.
@echo offFOR /L %%a IN (1,1,9) DO (echo sel disk 0echo sel par %%aecho det par ) | diskpart.exe | find.exe /I "c12a7328-f81f-11d2-ba4b-00a0c93ec93b" && ( echo disk 0 partition %%a (echo sel disk 0 echo sel par %%a echo assign letter=S ) | diskpart.exe)
Should work in most cases, will fail at strange machines or configurations.There is no general way.
Oh, thank you, Cdob.
diskpart have det command but i do not know it.
So may it is safe way to detect EFI partition.
No general way >> Of course, there's no such thing as perfect.
I still have a question, can you explain it for me??
With computer has 2 disks, we can say that the disk which windows boot from always show as disk 0 in diskpart ?? Not matter with internal or external ??
Because i will hard code like you, .bat will copy .efi file to disk0 by default. Before do this, we must sure that disk which windows is running is disk 0
0 -
I have been using some other method to detect a specific VOLUME by reading the name of the label. So you could also look into adding a specific label to your ISO.
I use this method in a batch file to automatically create a SVN Depot on the volume with the label BACKUP:
@echo off::check if SVN depot existsfor /f "tokens=3,4 skip=9 delims= " %%i in ('cmd /c ^"echo list volume ^| diskpart^"') do ( if /i %%j==BACKUP set SVNPATH=%%i:\SVN depot)if not defined SVNPATH set SVNPATH=%SystemDrive%\SVN depotif not exist "%SVNPATH%" md "%SVNPATH%"::Create SVN servicesc create svnserve binpath= "\"%ProgramFiles%\TortoiseSVN\bin\svnserve.exe\" --service --root \"%SVNPATH%\"" displayname= "Subversion" depend= tcpip start= autonet start svnserve
First, tks for your hint. I'll copy your code and save to my_bat_collection.txt file. I'm learning about token and delims. Your example is very helpful.
But i must say sorry to you, because your case is not same with mine, and i can't use it.
My .bat was create for user run to mount ISO file after boot to WinPE and it cannot find ISO file base on Label since Label is named by user.
But, even your code is not work for my case, it still is good example for me study .bat code.
Tks Acheron.
0 -
Hi, Jaclaz.
I'm so sorry when ask you again. I try to know how each line in your code work.
i'm very interested with your combine math in .batch.
Let say about limited number in .bat
2 months ago, I pratice using fsutil to create a blank file with specific size
Fsutil file createnew abc def
(abc is file name and def is kb in size)
My problem is create a file, that say about 2Gb then convert it to ext2 for running some LinuxOS persistence.
My .bat
set /p size=Enter size (in Gb):
set /a size=%size% * 1073741824
Fsutil file createnew C:\persist %size%
But .bat limited number and then if file size more than about 1.3Gb (not remember exactly number), .bat will error
How can I solve this problem?? Tks
Edit: I want to create exactly file size. ( 1024 Mb for 1Gb).
0 -
Of course it is just a joke to show an example of zeroless pandigitals:Hmm, I know a new thing. About 0x9EA*2538+0x44F1*17649. Very very smart way to detect if chosen is invalid or not.
http://www.worldofnumbers.com/ninedig1.htm
SureHow do you think about
echo %chose%|findstr /r "[^1-9]"
TKs.
, that is a "normal" way, but findstr in some cases is extremely slow, and that way the user might input a "special" character like '"%&!()<>| that may make the batch fail, actually it should be:
FOR /F "delims=123456789" %%? IN ("!chosen!") DO ...
to take advantage of delayed expansion, see:
http://www.robvanderwoude.com/battech_inputvalidation_setp.php
About Mountvol, if I recall correctly, it is "self-standing", i.e. just adding mountvol.exe to the liveXP build it should work.
jaclaz
Ah, in .batch, some characters such as ^ ! will make .bat error.
About mountvol.exe, it's not my problems. I just want to avoid using mountvol in .bat, because if user run .bat in liveXP it will fail.
You help me with fsutil. It work and seem all rebuild of WinPE, fsutil is always exist. It's safe way to get letter.
1 -
Yep, and this is (yet another) can of wormsAnd now, only 1 problem as you and cdob say, in case computer has 2 disk. I think I must hard code that .bat will copy .efi file to disk0. But not sure what disk0 means in computer has 2 disk.
, AFAIK/AFAICR with SATA (and UEFI) a number of motherboards do not always assign disk numbers in the "same" order.
jaclaz
Seem i cannot have a .bat using in general way. If some computer with special order disk/partition then user must use .bat as semi-automatic (hope that it is not common)
Thank you very much, Jaclaz.
0 -
Hmm, I know a new thing. About 0x9EA*2538+0x44F1*17649. Very very smart way to detect if chosen is invalid or not.
How do you think about
echo %chose%|findstr /r "[^1-9]"
TKs.
1 -
Only to show off a little bit
and to have an occasion to use some math in the batch
, how I would write the stuff:
@ECHO OFFSETLOCAL ENABLEDELAYEDEXPANSIONSET lookfor=ToolsforPE.ISOSET /A Counter=0FOR /F %%A in ('MOUNTVOL^|FIND ":\"') do (dir /b %%A%lookfor% >nul 2>&1 && (SET /A Counter+=1set isofile[!Counter!]=%%A%lookfor%))SET /A §=0x9EA*2538+0x44F1*17649IF NOT DEFINED isofile[1] ECHO NO iso file was found&GOTO :endECHO Found !counter! item(s):FOR /F "tokens=2,3 delims=[]=" %%A IN ('SET isofile') DO ECHO %%A - %%BIF !counter!.==1. SET chosen=1&GOTO :past_choice:choice_loopSET /P chosen=Please choose item number:FOR /F "delims=%§%" %%? IN ("%chosen%") DO ECHO Invalid input&GOTO :choice_loopIF %chosen% GTR %Counter% ECHO Invalid input&GOTO :choice_loop:past_choiceECHO You chose item #%chosen% which is isofile[%chosen%] i.e. !isofile[%chosen%]!:endECHO.ECHO End of batch
jaclazOh, very nice output. You are genius.
But mounvol not exist on LiveXP and i want try to change your code with fsutil. Tks.
1 -
I test quite many cases and seem it work fine.
First, I want to say thanks to you, Jaclaz, not only this topic, almost topic which I created, you always help me. I know that i'm very stupid and sometimes I ask some stupid question. Please forgive me.
Without you, this .bat will never improve.
Let me say something, from begin, when i got trouble with fsutil in XP, then I must try
fsutil fsinfo drives > list.txt
then
type list.txt | findstr /r %type% and then output if user type a letter which already use.
Jaclaz, you help me with for /f token. It work very very perfect.
And then, I want to list if there are more than 1 ISO found, you, again help me with a greate code. It's not new for you, but it's very greate for me.
I know about "path" variable, about !, [ ] in .batch. Not know all, but a little
Finally, with bphlpt's hint, i try to hidden echo output and successed.
Just want to say milion thanks to both of you. And again i'm sorry for my bad English, for my bad .bat, for all.
God bless you.
1 -
No, isopath work fine for me. It return that there is/are 2 ISO found on c: d:
You're right, I missed that. Sorry.
Good luck fixing the rest of the issues.
Cheers and Regards
Yeah, i got it. It work fine but i'm not sure if it's not logical. Full code:No, i'm wrong
@ECHO OFFSETLOCAL ENABLEDELAYEDEXPANSIONSET /A Counter=1for %%b 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 (dir %%b:\ToolsforPE.ISO >nul 2>nul && (set isopath=!isopath! %%b:set isofile[!Counter!]=%%b:\ToolsforPE.ISO&&SET /A Counter+=1goto :found)):notfoundecho ISO not foundpauseexit:foundset /A counter2=%counter%-1echo there is/are %counter2% ISO found on%isopath%pauseexit
EDIT:
Oh, i'm sorry, it not return the true counter (always return is 1)
I'll try again.
EDIT2: seem it work fine. I will test more case to make sure.
@echo offSETLOCAL ENABLEDELAYEDEXPANSIONSET /A Counter=0for %%b 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 (dir %%b:\ToolsforPE.ISO >nul 2>nul && (set isopath=!isopath! %%b:set isofile[!Counter!]=%%b:\ToolsforPE.ISO&&SET /A Counter+=1)IF NOT DEFINED isofile[0] echo >nul)if "%counter%"=="0" echo ISO not found && pause && exitif "%counter%"=="1" echo there is %counter% ISO file found on %isopath% && pause && exitecho there are %counter% ISO files found on %isopath%pauseexit
EDIT3:
try to remove IF NOT DEFINED since we not use it. It's work.
@echo offSETLOCAL ENABLEDELAYEDEXPANSIONSET /A Counter=0for %%b 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 (dir %%b:\ToolsforPE.ISO >nul 2>nul && (set isopath=!isopath!%%b:set isofile[!Counter!]=%%b:\ToolsforPE.ISO&&SET /A Counter+=1))if "%counter%"=="0" echo ISO not found && pause && exitif "%counter%"=="1" echo there is %counter% ISO file found on %isopath% && pause && exitecho there are %counter% ISO files found on %isopath%pauseexit
1 -
I will try again.
The data in the "Info" column in diskpart DOES NOT EXIST
, it is generated dynamically.
You can have n disks each with a FAT32 EFIsys partition, but only one partition on one disk will have the "System" tag in diskpart, the one that was actually used for booting the running system or, if you booted (say) a PE of some kind, NONE of them will have that tag.
Each of the FAT32 EFIsys partition on each of the n disks may instead have a "SYSTEM" label, which UNLIKE the "Info" is a "static" value.
So, looking for the "System" tag in "Info" can return one or no result, while looking for "SYSTEM" in "Label" may return more than one result.
I hope now the point is more clear.
jaclaz
As you say, I test diskpart list vol from WinPE, now it say that, EFI partition is Hidden (in Info column). So i must have some lines to detect if user run .bat from winPE. It must be run in real Windows, and diskpart will show as system.
About label SYSTEM, you're right again. diskpart still say SYSTEM in label column. But i run partition wizard and change this label to SYSTEM1 and boot again to windows 10, run diskpart, it say that label is SYSTEM1.
So, SYSTEM label is can be change if user want. system in info column is change to hidden when run diskpart from winPE.
>> Only one way is .bat must be run from real windows.
And now, only 1 problem as you and cdob say, in case computer has 2 disk. I think I must hard code that .bat will copy .efi file to disk0. But not sure what disk0 means in computer has 2 disk.
0 -
1) jaclaz told you, and you say you understand, that "path" is a system variable with a defined use
I change is to isopath but there are some typos on above post. But in my .bat from my computer, all was change to isopath.
3) Even if you fix your "path" issue, the way your code is now the "there is/are ... " line will have the count correct but only list the location of the last one foundNo, isopath work fine for me. It return that there is/are 2 ISO found on c: d:
Just only problems is if ISO not put to C:, then it still echo no ISO found and then echo there is/are 1 ISO found on d:
I repost my .bat again
@echo offSETLOCAL ENABLEDELAYEDEXPANSIONSET /A Counter=1for %%b 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 (dir %%b:\ToolsforPE.ISO >nul 2>nul && (set isopath=!isopath! %%b:set isofile[!Counter!]=%%b:\ToolsforPE.ISO&&SET /A Counter+=1)IF NOT DEFINED isofile[1] echo ISO not found)set /A counter2=%counter%-1echo there is/are %counter2% ISO found on %isopath%pause
Tks for your hint, I will try to find out and then report.
1 -
Tks for your reply, bhplpt.
counter-1 is the number of ISOs that have actually been found
of course. Because from we begin, we set counter=1.
But since you say,
You seem to think that "counter" is the number of ISOs found. Counter is just a sort of placeholder that will be used for the index of the NEXT ISO that might be foundyou're right. I think that (from my above post) and i'm wrong.
echo there is/are %counter% ISO found on %path%
May Jaclaz was try to talk to me as you say. But he choose other way to explain to me and it make me quite difficult to understand
If you want to set initially Counter to 0 (or to 42) is good as well, as long as you make the check for isofile[0] or for isofile[42].I'm stupid and I must say sorry Jaclaz.
----
So i must add a line,
set /a counter2 =%counter% - 1
and then full code is
@echo offSETLOCAL ENABLEDELAYEDEXPANSIONSET /A Counter=1for %%b 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 (dir %%b:\ToolsforPE.ISO >nul 2>nul && (set path=!path! %%b:set isofile[!Counter!]=%%b:\ToolsforPE.ISO&&SET /A Counter+=1)IF NOT DEFINED isofile[1] echo ISO not found)set /A counter2=%counter% - 1echo there is/are %counter2% ISO found on %isopath%pause
Tested in 3 cases:
- case 1: 0 ISO put on any partition.
.bat return ISO not found but quite much lines. must to improve it.
ISO not found
ISO not found
.....
ISO not found
there is/are 0 ISO found on- case 2: 1 ISO on C:
.bat return
there is/are 1 ISO found on c: <<<<< perfect.- case 3: 1 ISO (or even 2, 3 ...) but put on D: (and E: F:) not C:
.bat return
ISO not found <<< Why ? and How can I improve .bat
there is/are 1 ISO found on d:Conclution:
0 ISO: .bat return very many lines say that 0 ISO found
1 ISO (or 2, 3 ...) but put it on from D: (pass C:) then .bat count ISO right but still has a line say that ISO not found
1 ISO (or 2 , 3 ...) and put on from C: then .bat work perfect.
Can you explain me why?? Tks
1 -
Now i recreate .bat file. It something like
- detect if user boot from real windows, not WinPE (just to make sure diskpart will show EFI par is system in info label)
- detect if user run .bat from windows which boot with UEFI mode. Base on this
if that's true next to step 3, exit if fail
- if windows boot with UEFI mode, then of course always have at least 1 EFI partition found and of course it is in harddisk which current windows running and .bat will continue
- check to get order of EFI partition by combo "for /f command" + "diskpart" (tks to Jaclaz). (Jaclaz hint using signal SYSTEM label to detect but i worry about this label can be change by some partition tool, system in info column is shown by diskpart, it may cannot be change ??? )
- count EFI partition
+) if only 1 EFI partition found >> mount it as S: recheck to make sure it is EFI by EFI\Boot\Microsoft\BCD file
+) if there are more than 1 EFI par found >> echo more than 1 EFI par found !! this .bat will only copy .efi file to EFI partition of disk 0 (which windows boot from current ??) >> ask user for make sure, type Y to continue, type N to exit.
Can both of you give me some advices about my ideal ?? Such as it's will not work in some case (which case), or how can I improve this ideal ??
Tks
p/s: To cdob: Using EFI system partition GUID C12A7328-F81F-11D2-BA4B-00A0C93EC93B to detect EFI partition is a safety way but I do not know which command to get GUID of partition.
0 -
Please note that I am saying something slightly different.
If you have one disk (GPT) with a UEFI Windows installed on the default EFIsys type partition, if you run the command from that booted OS (the one that was booted from that disk) then you will have the "System" in "Info".
If you boot a PE from (say) CD/DVD, there won't be a "System" in "Info" (and then the label of "SYSTEM" might be of use).
But if you have two disks, each with a EFIsys partition you will have a problem as two volumes with FAT32 in Fs and with EITHER "SYSTEM" as label OR "System" in "Info" will be found and listed.
And BOTH will have a \EFI\Boot\microsoft\bcd in them.
So you may need to LIST DISKs, and then DETAIL each of them.
jaclaz
Oh, Sorry for my confusion and thanks for the clarification.
How many disks do you use at one machine?I'm creating .bat file will mount EFI partition by diskpart. But I'm not sure what partition order in Windows UEFI
Did you boot windows from this UEFI disk?
mountvol.exe S: /S
.Did you like to support another disk, not booted from this one?
The specs request a EFI system partition GUID C12A7328-F81F-11D2-BA4B-00A0C93EC93B https://en.wikipedia.org/wiki/EFI_system_partition
There may be two hard disks with this GUID at one machine.
Your question may same with Jaclaz. Thank you, too.
So I think problem is simple, but it does not. As both of you say, I have to create a .bat in "general" way.
I create .bat from my Windows, from my laptop, and test from my laptop. It work fine for me but not sure that it will work with others.
Now may I will create a .bat which only allow user copy .efi file to EFI partition of hard disk which user boot from. Not boot from this harddisk then install some .efi boot menu (Ubuntu,...) to another hard disk.
But can I have a question?
If we have 2 (or 3 ...) hard disk with 2 case
- case1: both of hard disk is internal hard disk (HDD + SDD), then if we boot windows from HDD, diskpart will say HDD is disk 0 ??
- case2: if one is internal and one is external, then if we boot Windows from External, diskpart will say external is disk 0 or disk 1 ??
Tks all of you for your enthusiasm.
Edit: to cdob, tks for your hint but i found that mountvol not have /s parameter. Run from windows 10.
0 -
results in isofile[1] NOT DEFINED if the iso has not been found.
What is the problem?
If you want to set initially Counter to 0 (or to 42) is good as well, as long as you make the check for isofile[0] or for isofile[42].
Your code work fine if there is not ISO was found. But i want to ask you that in case we have 1 (or 2, 3 ...) then if we set counter=1, then if 1 ISO found it will return counter=2, if 2 ISO found it will return =3. I tested it before ask you. Tks
1 -
Sorry for miss this.
After replace path with mypath as you say, it work fine.
Again, you teach me that: PATH is a "special" variable in Windows (and in DOS for this matters). Tks.
You help me in more ways than you realize.
1 -
Well, no.
You need to study a minimal of the environment and of the batch syntax.
PATH is a "special" variable in Windows (and in DOS for this matters).
And you are not really "new" to batch, it's like two years that you are a member of MSFN and try writing small batches.
It seems like you take one snippet here (and one there) than modify them in a "random" or "semi-random" way and as soon as they don't work you ask for help here and as soon as you get an EXAMPLE, instead of studying it and trying to understand why it works (or why it doesn't work) you further modify it in a random or semi-random way, and this leads to another loop.
Try using "mypath" or "isopath" instead of "path" in that batch.
jaclaz
You're right. I'm not an coder and not usually work with code. I'm an economic students. But i love to know anything about "windows, booting" such as grub4dos, batch, ...
Before ask for help, i always write and test it myself. I read very many times from this link but still do not know all about .batch, even just for /f command.
After some examples which you give me, i learn a little from it. about !, about tokens, about delims about [ ] ...
You help me in almost topic which I created and I'm sorry for about 2 year, from this topic to this topic, i'm still not know much about .bat and then you spend quite time and patient to help me.
About isopath if there are more than 1 ISO found, may i do not neet. Just simply output search result then ask user rename before rerun .bat
But still need you explain a thing, please
why we need set counter = 1 instead of 0. Output will return 1 even if ISO was not found.Tks, Jaclaz.
1 -
As often happens, yes and no.Can we say that: Microsoft EFI partition is always show as "system" (in info column) by diskpart ??
It is IF seen from the booted OS from that disk.
The "System" or "Boot" in the "Info" column are not a "fixed" attribute, if you boot another OS (from another media/device) that volume will be a volume like any other one with no such attribute.
Looking for cAsE UnSeNsItIve string "System" might work in your case because also the volume label is "SYSTEM", but cannot say if this is a (recent) Windows "standard", in any case, if you have more that one disk with independent Windows installs this latter "feature" may be unwanted.
jaclaz
OK, tks for your hint. Label SYSTEM may can be edit by some partition tool (not sure). But i think that system (in info column) is fixed and not any tool can change this.
And as you say, it may change with latter Windows OS, or it may change when boot from another OS (WinPE ??), so i must add some conditions to .bat to make sure that, user only run .bat from within Windows 7 or above (and of course, with GPT disk).
And may I need to add "if exist" command, after mount EFI partition (that say S:), then check if exist S:\EFI\Boot\microsoft\bcd to make sure.
Thank you very much, Jaclaz.
:thumbup
0 -
However, what do you think would be the effect of:
SET cdletter=%cdletter:\=%
Never better.
Then strip them ... not that of writing the batch for youWell, i'm sorry. Because i'm new with batch command then just want to ask you to make sure.
Before ask you again, i try with this command (base on yours) but it not work properly
Yours
@ECHO OFFSETLOCAL ENABLEDELAYEDEXPANSIONSET list=FOR /F "tokens=*" %%A IN ('FSUTIL FSINFO DRIVES ^| FIND ":"') DO SET list=!list! %%AFOR /F "tokens=2,* delims= " %%A IN ('ECHO %list%') DO SET list=%%A %%B
return: C:\ D:\ E:\ ..
I add this line
FOR /F "tokens=2,* delims=\ " %%A IN ('ECHO %list%') DO SET list=%%A %%B
but it return C: D:\ E:\ (D, E not work and i'm not good at .bat to know why)
and then i ask you to get your help.
For /F "tokens=3,5 delims=\ " %%A IN ('REG QUERY HKLM\SYSTEM\MountedDevices /s ^|FIND "\DosDevices\" ^| FIND "4300640052006F006D"') DO set CDROM=!CDROM! %%ASET CDROM
still not work after check each letter. But you help me with fsutil is enough for me, tks.
Return my question
SETLOCAL ENABLEDELAYED EXPANSIONSET /A Counter=1for %%b 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 (dir %%b:\ToolsforPE.ISO >nul 2>nul && (set isofile[!Counter!]=%%b:\ToolsforPE.ISO&&SET /A Counter+=1)IF NOT DEFINED isofile[1] echo ISO not foundbla ...
I try to add a line which set path=%%b to get letter where ISO found.
full code
@echo offSETLOCAL ENABLEDELAYEDEXPANSIONSET /A Counter=1for %%b 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 (dir %%b:\ToolsforPE.ISO >nul 2>nul && (set path=!path! %%b:set isofile[!Counter!]=%%b:\ToolsforPE.ISO&&SET /A Counter+=1)IF NOT DEFINED isofile[1] echo ISO not found)echo there is/are %counter% ISO found on %path%pause
but it return
there is/are 3 ISO found on C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\ c: d:
Don't know why
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\
exist on output.
And just ask for sure, why we need set counter = 1 instead of 0. If set to 1, then if ISO was not found, it will output 1 ISO found.
tks
1 -
This should work then:
FOR /F "tokens=* delims= " %%A IN ('ECHO list volume^|diskpart^|FIND "FAT32"^|FIND /I "System"') DO ECHO %%AMaybe it is another issue with copy/paste through the board?
, it should "filter" the only line with both "FAT32" and "System" in it.
Try separating the issues:
ECHO list volume|Diskpart>result.txt
TYPE result.txt|FIND "FAT32"
TYPE result.txt|FIND /I "System"
TYPE result.txt|FIND "FAT32"|FIND /I "System"
jaclaz
Oh i'm sorry. Your code work fine, even very perfect. All i need is run as admin .bat file.
I think that just need to turn off UAC then reboot but no luck. Must run as admin.
Now, there only one thing that i'm not sure. it's using "system" (in info column) to get EFI partition.
Can we say that: Microsoft EFI partition is always show as "system" (in info column) by diskpart ??
0 -
Oh, I was found that link before create this topic. But it is not same with my problems.
That is detect if EFI partition was assign a letter for it.
Mine is how to determine what is EFI partition number to select it from diskpart then use diskpart to assign a letter.
Sure, it is not EXACTLY what you want, but it does show you an EXAMPLE on how to parse the diskpart list volume.
An EXAMPLE is something that you need to ADAPT to your needs.
In this specific case, the diskpart command is a single one, so a simpler pipe should do:
Try on your system running this and post the output:
FOR /F "tokens=* delims= " %%A IN ('ECHO list volume^|diskpart^|FIND /I "efisys"') DO ECHO %%A
I havent' handy a winows 7 or later system with a EFI/GPT disk to check the output of diskpart, this might also do:
FOR /F "tokens=* delims= " %%A IN ('ECHO list volume^|diskpart^|FIND "FAT32"^|FIND /I "System"') DO ECHO %%A
jaclaz
Run both code it just pop up diskpart dialogue, not display or run anything
My diskpart list volume in case you need
Volume ### Ltr Label Fs Type Size Status Info
---------- --- ----------- ----- ---------- ------- --------- --------
Volume 0 J DVD-ROM 0 B No Media
Volume 1 C WINDOWS 10 NTFS Partition 70 GB Healthy Boot
Volume 2 G UBUNTU FAT32 Partition 14 GB Healthy
Volume 3 D BACKUP NTFS Partition 100 GB Healthy
Volume 4 E DATA NTFS Partition 47 GB Healthy
Volume 5 Windows RE NTFS Partition 300 MB Healthy Hidden
Volume 6 SYSTEM FAT32 Partition 100 MB Healthy System <<<< EFI Par
Volume 7 F HP_TOOLS FAT32 Partition 700 MB Healthy Hidden
And if run diskpart list partition
Partition ### Type Size Offset
------------- ---------------- ------- -------
Partition 1 Recovery 300 MB 1024 KB
Partition 2 System 100 MB 301 MB <<<<< EFI par
Partition 3 Reserved 128 MB 401 MB
Partition 4 Primary 70 GB 529 MB
Partition 5 Primary 14 GB 70 GB
Partition 6 Primary 100 GB 85 GB
Partition 7 Primary 47 GB 185 GB
Partition 8 Recovery 700 MB 232 GB
list partition not the same list vol.
0 -
#1: I'm at home now and very happy to say that your code work very very perfect.
But it return how many ISO found, how can I output path of each iso was found by .bat too ?
#2: Again, just want to say tks to you.
Run your code from LiveXP, fsutil with nul in output result now is not problems.
But how can I improve it, instead of A:\ B:\ ... I only need A: B: ...
#3
Oh, my bad.
of course that batch will return a single drive letter for the CD-rom, the LAST CD-ROM device found.The diffrences between yours and mine is
set cdletter=!cdletter! %%A
And you right, no need to looking for the drive letter. But not luckily, LiveXP i'm using does not exist moutvol.
But when i run your code, it return
CD-ROM drive letter is !cdletter! h
(H is right, but it is virtual CD, the real one is F)
#4 Run
For /F "tokens=3,5 delims=\ " %%A IN ('REG QUERY HKLM\SYSTEM\MountedDevices /s ^|FIND "\DosDevices\" ^| FIND "4300640052006F006D"') DO set CDROM=!CDROM! %%ASET CDROM
returns
CDROM=!CDROM! REG_BINARY
just copy yours and paste to notepad, do not know why it does not work. Tks
1 -
Sure, partition order is NOT compulsory.
But the EFI System partition (the FAT32 formatted one containining the EFI bootmanager will always be of the EFIsys type.
Something like this:
might do nicely.
JFYI, and as a side note, there is a trick to avoid making the temporary file to feed commands in diskpart, see here:
You can find here another example of the technique:
jaclaz
Oh, I was found that link before create this topic. But it is not same with my problems.
That is detect if EFI partition was assign a letter for it.
Mine is how to determine what is EFI partition number to select it from diskpart then use diskpart to assign a letter.
If there is no way to do that, may I must create a semi-automatic .bat
- Ask some one use disk manager to check EFI partition number, it's FAT32, label is system, size about 100Mb, ... then if it is partition 2 (show as disk manager) then
- type 2 to .bat prompt then .bat will run diskpart sel disk 0 sel par 2 assign letter=s and copy file to here ...
I hope that it's last solution. But now maybe it's only one solution.
---
About running diskpart without need a config file I will try it. Many tks for greate guide, Jaclaz.
0 -
It is just a "safety" measure (and to use some consistency).
There is no real difference on a modern, recent system, the same batch script will run the same as either .bat or as .cmd.
In theory a .bat should be associated to command.com (and it would be an actual "dos" batch), whilst a .cmd should be associated to cmd.exe (and it would be a NT batch, NOT a "dos" one, on all NT systems when you open the command prompt or the command window you are NOT running dos, you are running the NT command interpreter).
But if you use batches on different OS's you might need to put in them checks to make sure they run on the "right" OS or "refuse" to run on a non-expected OS.
If you name a NT batch as .cmd it will NOT run on DOS (MS-DOS or FreeDOS, etc.) and on 9x/Me.
jaclaz
Many thanks for your clarification, Jaclaz.
I only use this .bat to mound ISO file when boot to WinPE or LiveXP. And I got problems with fsutil fsinfo drives only with LiveXP cmd. (as I report above). But I think your .bat code solved my problem (I will report as I can test it).
By using fsutil, I do not need to check if a letter drive is CD/DVD. But as you say
The detection of CD-Rom drive letter is not a "new" problemso can you give me some link
And it's not specific to my PE build. On my real Windows, I got this problems too.
I have a real CD/DVD with F: drive letter, and a virtual CD/DVD with G: (after install UltraISO). And if use
for %%a 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 (fsutil.exe fsinfo drivetype %%a:|find "CD-ROM">nul&&set cdletter=%%a)echo CD-ROM drive letter is %cdrom%
then it return CD-ROM drive letter is H. In winPE, if an ISO file was mounted to such as Y:, then it return Y, not F, or not both F and Y.
- I found from your code some special characters. such as ! [ ] in variable, can you give me some links about these? Tks
1
[Request] Create file with specific size
in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Posted
Oh i'm sorry.
I think that this is a small quetion, and I created 2 topics on one day (one about For /f command and one about EFI partition). I don't know if it is kind of spam or not when i create the third topic.
---
I just use fsutil to create a empty file, then use mke2fs as Jaclaz say. I know that fsutil just create a file, not ext2 file. But tks for your explain.