jaclaz Posted February 25, 2016 Share Posted February 25, 2016 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.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 1 Link to comment Share on other sites More sharing options...
congnt92 Posted February 25, 2016 Author Share Posted February 25, 2016 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.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. Link to comment Share on other sites More sharing options...
cdob Posted February 25, 2016 Share Posted February 25, 2016 i found that mountvol not have /s parameter. Run from windows 10.Mountvol does support /s parameter, if you boot at UEFI mode. This includes Windows 10. Mountvol dosn't support /s parameter, if you boot at BIOS mode. How do you boot the machine? Link to comment Share on other sites More sharing options...
cdob Posted February 25, 2016 Share Posted February 25, 2016 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. 1 Link to comment Share on other sites More sharing options...
congnt92 Posted February 26, 2016 Author Share Posted February 26, 2016 (edited) 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 Edited February 26, 2016 by congnt92 Link to comment Share on other sites More sharing options...
jaclaz Posted February 26, 2016 Share Posted February 26, 2016 JFYI, diskpart has some "shortened commands", *like*:sel=selectdet=detailpar=partitionetc. jaclaz 1 Link to comment Share on other sites More sharing options...
congnt92 Posted February 26, 2016 Author Share Posted February 26, 2016 JFYI, diskpart has some "shortened commands", *like*:sel=selectdet=detailpar=partitionetc. jaclazI know about sel, par but not know what does det mean. Now you explain it. Tks. Link to comment Share on other sites More sharing options...
congnt92 Posted February 27, 2016 Author Share Posted February 27, 2016 Hi,I repost this to get some advices from you.Cdob's method seem work in most case, even if user run .bat from WinPE (not yet tested)But for safety reason, i just want user run .bat from real windows.I found a useful reg key to check if user boot from winpe or not HKLM\SYSTEM\Controlset001\Control\SystemStartOptions If boot from winpe, that say Win7PE then it will show ..\Win7PE.Wimso i use reg query command then use findstr /r "WIM", if not error then user boot from winpe.Since LiveXP use .wim boot method then I think this will work with LiveXP, too.But just to make sure, I want to ask you if it's good method or we can use another method to detect. Tks Link to comment Share on other sites More sharing options...
jaclaz Posted February 27, 2016 Share Posted February 27, 2016 Well, if you are going to look in the Registry, then you could probably check also:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Firmwarebootdevicebut this is 7 and later only. More generally, you should always use the CurrentControlSet or check manually the Select hive on a live system, you cannot assume that Current is ControlSet001. jaclaz 1 Link to comment Share on other sites More sharing options...
congnt92 Posted February 27, 2016 Author Share Posted February 27, 2016 Well, if you are going to look in the Registry, then you could probably check also:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Firmwarebootdevicebut this is 7 and later only. More generally, you should always use the CurrentControlSet or check manually the Select hive on a live system, you cannot assume that Current is ControlSet001. jaclaz Oh i do not know that. I found this reg key from internet and even do not understand it work for general way or not.Can you give me some other ways simpler and quicker ?? Link to comment Share on other sites More sharing options...
jaclaz Posted February 27, 2016 Share Posted February 27, 2016 About CurrentControlSet:https://support.microsoft.com/en-us/kb/100010 There are several keys that one can check:PE 2.x and later:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\WinPEPE 1.x and later:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\MiniNTbut there is SystemSetupInProgress (but this may be re-set to 0 intentionally in the build to allow runnign some programs) and more:http://www.911cd.net/forums//index.php?showtopic=2840 jaclaz 1 Link to comment Share on other sites More sharing options...
congnt92 Posted February 27, 2016 Author Share Posted February 27, 2016 About CurrentControlSet:https://support.microsoft.com/en-us/kb/100010 There are several keys that one can check:PE 2.x and later:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\WinPEPE 1.x and later:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\MiniNTbut there is SystemSetupInProgress (but this may be re-set to 0 intentionally in the build to allow runnign some programs) and more:http://www.911cd.net/forums//index.php?showtopic=2840 jaclazTks for your info, i will try and report result. Link to comment Share on other sites More sharing options...
cdob Posted February 27, 2016 Share Posted February 27, 2016 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 ??I doubt always, very often it's disk 0. A user may change UEFI boot order: current running windows disk 0, second disk 1 The user changes the boot order: next boot is not from previous windows disk Possible execeptions Kansas chity shuffle http://www.911cd.net/forums//index.php?showtopic=21242 Machines with chipset storage and addional esata, msata or m.2 connector Imagine at two disk: given one EFI system partiton. You add a file this single EFI system partiton. The end user boot another OS next, creates a second EFI system partiton at the second hard disk. And boots from second hard disk next. Your file is missing at active EFI system partiton I don't understand the requirements still. Machinbe booted at BIOS? Machinbe booted at BIOS? What about EFI NVRAM settings? Remember, if you boot from UEFI, then mountvol solves your basic issue. Given the end user keeps the UEFI disk order. A real world simplification: If a disk 0 contains a EIF system, then use this. Ignore strange cases. By the way: At booted PE may reset SystemSetupInProgress settings, e.g. printer support 1 Link to comment Share on other sites More sharing options...
congnt92 Posted February 28, 2016 Author Share Posted February 28, 2016 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 ??I doubt always, very often it's disk 0.A user may change UEFI boot order: current running windows disk 0, second disk 1The user changes the boot order: next boot is not from previous windows diskPossible execeptionsKansas chity shuffle http://www.911cd.net/forums//index.php?showtopic=21242Machines with chipset storage and addional esata, msata or m.2 connectorImagine at two disk: given one EFI system partiton.You add a file this single EFI system partiton.The end user boot another OS next, creates a second EFI system partiton at the second hard disk.And boots from second hard disk next. Your file is missing at active EFI system partitonI don't understand the requirements still.Machinbe booted at BIOS? Machinbe booted at BIOS?What about EFI NVRAM settings?Remember, if you boot from UEFI, then mountvol solves your basic issue.Given the end user keeps the UEFI disk order.A real world simplification:If a disk 0 contains a EIF system, then use this. Ignore strange cases.By the way:At booted PE may reset SystemSetupInProgress settings, e.g. printer support Tks for your detail info.My goal:- At legacy bios, we can add a menu entry to boot.ini or BCD- At uefi, we can add menu to BCD but i do not know why it can not work quote from .bat (S: is EFI partition which mount by your method) for /f "tokens=3" %%a in ('bcdedit /create /d "Ubuntu" /application BOOTSECTOR') do set guid=%%abcdedit /set %guid% device partition=S:bcdedit /set %guid% PATH \EFI\Boot\grubx64.efi.... But it fail at Windows Boot manager. I guess that boot ubuntu.efi file from BCD is impossible. But this method work with memtest.efi. So may must be signed .efi ?? So i think that, i must replace bootx64.efi from Microsoft with bootx64.efi from ubuntu, then bootx64.efi from ubuntu config file grub.cfg, with grub.cfg i have a menu that chainload to bootfw.efi to boot windows and a menu to boot Live Ubuntu. By this method, i can dual boot windows and linux. And to copy bootx64.efi from ubuntu to EFI partition, I need a .bat to do this. You and Jaclaz help me solved it. My .bat request: User must run .bat from real UEFI windows (not PE). Link to comment Share on other sites More sharing options...
jaclaz Posted February 28, 2016 Share Posted February 28, 2016 (edited) Oh, my. Did you believe that grubx64.efi is a BOOTSECTOR? I guess you should think also about shimx64.efi, consult this (long) page:http://ubuntuforums.org/showthread.php?t=2147295and this one:http://linux.about.com/od/LinuxNewbieDesktopGuide/tp/3-Ways-To-Fix-The-UEFI-Bootloader-When-Dual-Booting-Windows-And-Ubuntu.htmBasically, dual booting on UEFI is a total mess, depending on single machines/firmwares and specific version of windows (and *what not* ) but, as you found out, normally you cannot add a multi-boot entry for Linux/GRUB2 to Windows BOOTMGR BCD on UEFI, you need to make GRUB2 (or Refind, etc.) your main bootmanager.jaclaz Edited February 28, 2016 by jaclaz 1 Link to comment Share on other sites More sharing options...
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