Jump to content

congnt92

Member
  • Posts

    128
  • Joined

  • Last visited

  • Donations

    $0.00 
  • Country

    Vietnam

Everything posted by congnt92

  1. 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.
  2. @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
  3. 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.
  4. 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).
  5. Of course it is just a joke to show an example of zeroless pandigitals:http://www.worldofnumbers.com/ninedig1.htm Sure , 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.
  6. Yep, and this is (yet another) can of worms , 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.
  7. 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.
  8. Oh, very nice output. You are genius. But mounvol not exist on LiveXP and i want try to change your code with fsutil. Tks.
  9. 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.
  10. 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%pauseexitEDIT: 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%pauseexitEDIT3: 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
  11. 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.
  12. 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. No, 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%pauseTks for your hint, I will try to find out and then report.
  13. Tks for your reply, bhplpt. of course. Because from we begin, we set counter=1. But since you say, you'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 I'm stupid and I must say sorry Jaclaz. ---- So i must add a line, set /a counter2 =%counter% - 1and 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%pauseTested in 3 cases: - case 1: 0 ISO put on any partition. .bat return ISO not found but quite much lines. must to improve it. - case 2: 1 ISO on C: .bat return - case 3: 1 ISO (or even 2, 3 ...) but put on D: (and E: F:) not C: .bat return 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
  14. 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.
  15. Oh, Sorry for my confusion and thanks for the clarification. How many disks do you use at one machine?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.
  16. 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
  17. 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.
  18. 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 Tks, Jaclaz.
  19. As often happens, yes and no. 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
  20. Never better. Well, 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 %%Breturn: 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. 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%pausebut 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
  21. Maybe 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 ??
  22. 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 %%AI 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 %%Ajaclaz 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.
  23. #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. The diffrences between yours and mine is set cdletter=!cdletter! %%AAnd 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 CDROMreturns CDROM=!CDROM! REG_BINARYjust copy yours and paste to notepad, do not know why it does not work. Tks
  24. 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.
  25. 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 so 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


×
×
  • Create New...