bingloverld Posted September 8, 2016 Author Share Posted September 8, 2016 This is not a problem. I make two winpe iso and I load them with modfied bcd boot menu als vhd image. Then run batch script. I have chosen this method because I have other boot tools on this drive (cloning software, antivirus, etc). Link to comment Share on other sites More sharing options...
jaclaz Posted September 8, 2016 Share Posted September 8, 2016 Sure not a problem but surely some redundancy/duplication/waste of storage. jaclaz Link to comment Share on other sites More sharing options...
Tripredacus Posted September 8, 2016 Share Posted September 8, 2016 DISM doesn't care regarding to /apply-image option, as long as it is a WIM file. Where the compatibility issues lie is with servicing images, which wouldn't be done in a PE anyways. Those include DISM from Win7 AIK can't service a Vista image and vice-versa. DISM for Win10 is needed for adding most signed drivers to Win10 images. You are correct, when you make a WinPE you don't have to copy in the imaging tools portion. It saves that short step because DISM is built-in. As far as advantages go... idk. MS deprecated imagex.exe in WinPE 3, even if it has been available in the current ADK. The only thing I ever use it for is the /info option but not while in a PE. 1 Link to comment Share on other sites More sharing options...
bingloverld Posted September 9, 2016 Author Share Posted September 9, 2016 Thank you, your all for such rich and nice help! Link to comment Share on other sites More sharing options...
bingloverld Posted September 9, 2016 Author Share Posted September 9, 2016 Ok, you fave right with redundancy/duplication/waste of storage. I have try change wim image in WinPE with menu: @ECHO OFF SETLOCAL ENABLEEXTENSIONS C: CD\ CLS :MENU ECHO ============= Installeren von Windows ============= ECHO ————————————————– ECHO 1. Windows 7 64bit - 29.08.2016 ECHO ————————————————– ECHO 2. Windows 10 LTSB ECHO ————————————————– ECHO ==========Drücken Q zum abbrechen========== ECHO. SET INPUT= SET /P INPUT=Bitte wählen Sie die Auswahl IF /I ‘%INPUT%’==’1’ GOTO Selection1 IF /I ‘%INPUT%’==’2’ GOTO Selection2 IF /I ‘%INPUT%’==’Q’ GOTO Quit CLS ECHO ============INVALID INPUT============ ECHO ————————————- ECHO Please select a number from the Main echo Menu [1-2] or select ‘Q’ to quit. ECHO ————————————- ECHO ======PRESS ANY KEY TO CONTINUE====== PAUSE > NUL GOTO MENU CLS :Selection1 SET wimdrive= FOR /F "tokens=1,2 " %%A in ('wmic logicaldisk get caption^,VolumeName 2^>NUL') do ( ECHO %%A %%B IF /I "%%B"=="wim" SET wimdrive=%%A ) IF DEFINED wimdrive ECHO Lauferk mit dem Namen "wim" wurde gefunden: %wimdrive% &&PAUSE&&GOTO :_doit ECHO wim-Laufwerk wird nicht erkannt :( PAUSE GOTO :EOF :_doit ECHO Jetzt wird alles automatich gemacht (diskpart, imagex(dism), bcdboot)! Diskpart /s %wimdrive%\mbr.txt %wimdrive%\Imagex.exe /apply %wimdrive%\win7_64bit_2016.wim 1 C: :Quit CLS C: CD Windows CD Syswow64 bcdboot C:\Windows /s S: ECHO Fertig. Bitte PC neu starten (exit befehl). :Selection2 SET wimdrive= FOR /F "tokens=1,2 " %%A in ('wmic logicaldisk get caption^,VolumeName 2^>NUL') do ( ECHO %%A %%B IF /I "%%B"=="wim" SET wimdrive=%%A ) IF DEFINED wimdrive ECHO Lauferk mit dem Namen "wim" wurde gefunden: %wimdrive% &&PAUSE&&GOTO :_doit ECHO wim-Laufwerk wird nicht erkannt :( PAUSE GOTO :EOF :_doit ECHO Jetzt wird alles automatich gemacht (diskpart, imagex(dism), bcdboot)! Diskpart /s %wimdrive%\gpt.txt dism /Apply-Image /ImageFile:%wimdrive%\win10.wim /Index:1 /ApplyDir:W:\ :Quit CLS C: CD Windows CD Syswow64 bcdboot W:\Windows /s S: /f ALL ECHO Fertig. Bitte PC neu starten (exit befehl). PAUSE :Quit CLS ECHO —————————————————- ECHO =============PRESS ANY KEY TO CONTINUE============== ECHO —————————————————- PAUSE EXIT But this is not working :(. Can you help me edit this script? Where I have made a mistake? Thank you! Link to comment Share on other sites More sharing options...
jaclaz Posted September 9, 2016 Share Posted September 9, 2016 What do you mean "it is not working"? It cannot find the drive or it doesn't accept user input? Or *something* else? I would guess that conditions like this: IF /I ‘%INPUT%’==’1’ GOTO Selection1 will NEVER be true (first quote on the left is ‘ while the one on the right of the equal sign is ’ Use "plain" double quotes or 'straight' single quotes like the rest of the world... IF /I "%INPUT%"=="1" GOTO Selection1 (though I suggested you an input routine which is much "safer") and of course you cannot have TWO labels ":_doit" the batch would be rather confused about them. jaclaz 1 Link to comment Share on other sites More sharing options...
bingloverld Posted September 9, 2016 Author Share Posted September 9, 2016 (edited) Here is my menu: I don't know why such ridiculous characters showing up?! On Notepad++ all is ok. Edited September 9, 2016 by bingloverld Link to comment Share on other sites More sharing options...
jaclaz Posted September 9, 2016 Share Posted September 9, 2016 You are likely using (and that might explain the "left" and "right" quotes), a "wrong" editor that "mixes" character sets (or possibly uses UNICODE) or you are saving the file in the "wrong" format. It is common enough, especially when copying and pasting from the Internet as a web page (or a forum post) may have "strange" formatting of characters. Open the .cmd in NOTEPAD (and nothing else) and try replacing what you may see as "-" dashes, with actual dashes and make sure to save as ANSI text. The cmd.exe command processor using a given encoding (which is similar to the DOS one, different from the usual Windows one), this is normally not an issue with any character in the ASCII table (i.e. code up to 127) but that has a few incompatibilities with the 128-255 range. jaclaz 1 Link to comment Share on other sites More sharing options...
bingloverld Posted September 9, 2016 Author Share Posted September 9, 2016 (edited) Ok, I don't know why I become this error (only with dism): "The system cannot find the path specified". PS When I write: dism /Apply-Image /ImageFile:F:\win10.wim /Index:1 /ApplyDir:W:\ (when we take that "wim" is F:) Can you please help me with detect for creating wim image second volume name: "windows" as 5th menu option. Thank you! PS "My" batch script It looks like this: wpeinit @ECHO OFF SETLOCAL ENABLEEXTENSIONS C: CD\ CLS :MENU ECHO ============= Bitte auswaehlen ======================= ECHO ----------------- ECHO 1. Windows 7 64bit - 29.08.2016 ECHO ----------------- ECHO 2. Windows 7 64bit - AutoCAD ECHO ---------------- ECHO 3. Windows 10 LTSB - mit BIOS ECHO ---------------- ECHO 4. Windows 10 LTSB - mit UEFI ECHO ---------------- ECHO ==========Bitte druecken Sie Taste-Q zum Abbrechen========== ECHO. SET INPUT= SET /P INPUT=Bitte waehlen Sie die Auswahl dannach bitte druecken ENTER: IF /I ‘%INPUT%’==’1’ GOTO Selection1 IF /I ‘%INPUT%’==’2’ GOTO Selection2 IF /I ‘%INPUT%’==’3’ GOTO Selection3 IF /I ‘%INPUT%’==’4’ GOTO Selection4 IF /I ‘%INPUT%’==’Q’ GOTO Quit CLS ECHO ============Falsche angabe============ ECHO --------------------------------------- ECHO Bitte wählen Sie die Nummer echo oder druecken Sie Taste-Q zum Abbrechen. ECHO --------------------------------------- ECHO ======Druecken Sie belibiege Taste====== PAUSE > NUL GOTO MENU CLS :Selection1 SET wimdrive= FOR /F "tokens=1,2 " %%A in ('wmic logicaldisk get caption^,VolumeName 2^>NUL') do ( ECHO %%A %%B IF /I "%%B"=="wim" SET wimdrive=%%A ) IF DEFINED wimdrive ECHO Lauferk "wim" wurde gefunden: %wimdrive% &&PAUSE&&GOTO :_doit ECHO Lauferk "wim" wurde nicht gefunden :( PAUSE GOTO :EOF :_doit ECHO Jetzt wird alles automatich gemacht (diskpart, imagex(dism), bcdboot)! Diskpart /s %wimdrive%\mbr.txt %wimdrive%\Imagex.exe /apply %wimdrive%\win7_64bit_2016.wim 1 C: :Quit CLS C: CD Windows CD Syswow64 bcdboot C:\Windows /s S: ECHO Fertig. Bitte PC neu starten (exit befehl). GOTO :EOF :Selection2 SET wimdrive= FOR /F "tokens=1,2 " %%A in ('wmic logicaldisk get caption^,VolumeName 2^>NUL') do ( ECHO %%A %%B IF /I "%%B"=="wim" SET wimdrive=%%A ) IF DEFINED wimdrive ECHO Lauferk "wim" wurde gefunden: %wimdrive% &&PAUSE&&GOTO :_doit2 ECHO Lauferk "wim" wurde nicht gefunden :( PAUSE GOTO :EOF :_doit2 ECHO Jetzt wird alles automatich gemacht (diskpart, imagex(dism), bcdboot)! Diskpart /s %wimdrive%\mbr.txt %wimdrive%\Imagex.exe /apply %wimdrive%\win7_64_autocad_07092016.wim 1 C: :Quit CLS C: CD Windows CD Syswow64 bcdboot C:\Windows /s S: ECHO Fertig. Bitte PC neu starten (exit befehl). GOTO :EOF :Selection3 SET wimdrive= FOR /F "tokens=1,2 " %%A in ('wmic logicaldisk get caption^,VolumeName 2^>NUL') do ( ECHO %%A %%B IF /I "%%B"=="wim" SET wimdrive=%%A ) IF DEFINED wimdrive ECHO Lauferk "wim" wurde gefunden: %wimdrive% &&PAUSE&&GOTO :_doit3 ECHO Lauferk "wim" wurde nicht gefunden :( PAUSE GOTO :EOF :_doit3 ECHO Jetzt wird alles automatich gemacht (diskpart, imagex(dism), bcdboot)! Diskpart /s %wimdrive%\mbr.txt dism /Apply-Image /ImageFile:%wimdrive%\win10.wim /Index:1 /ApplyDir:C:\ :Quit CLS C: CD Windows CD Syswow64 bcdboot C:\Windows /s S: /f ALL ECHO Fertig. Bitte PC neu starten (exit befehl). GOTO :EOF :Selection4 SET wimdrive= FOR /F "tokens=1,2 " %%A in ('wmic logicaldisk get caption^,VolumeName 2^>NUL') do ( ECHO %%A %%B IF /I "%%B"=="wim" SET wimdrive=%%A ) IF DEFINED wimdrive ECHO Lauferk "wim" wurde gefunden: %wimdrive% &&PAUSE&&GOTO :_doit4 ECHO Lauferk "wim" wurde nicht gefunden :( PAUSE GOTO :EOF :_doit4 ECHO Jetzt wird alles automatich gemacht (diskpart, imagex(dism), bcdboot)! Diskpart /s %wimdrive%\gpt.txt dism /Apply-Image /ImageFile:%wimdrive%\win10.wim /Index:1 /ApplyDir:W:\ :Quit CLS W: CD Windows CD Syswow64 bcdboot W:\Windows /s S: /f ALL ECHO Fertig. Bitte PC neu starten (exit befehl). GOTO :EOF CLS ECHO ------------------ ECHO =============Druecken Sie belibiege Taste============== ECHO ------------------ PAUSE>NUL EXIT Edited September 10, 2016 by bingloverld Errors in script Link to comment Share on other sites More sharing options...
jaclaz Posted September 10, 2016 Share Posted September 10, 2016 For the moment I just re-ordered/re-compacted your script, this way it should be easier to read (and modify when needed) without (hopefully) changing anything in the commands that are actually executed and in the messages to the user. (BTW isn't it Laufwerk and not Lauferk?) @ECHO OFF SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION ::Let's check first thing if a volume with label "wim" is found, otherwise there is no sense to go on SET wimdrive= FOR /F "tokens=1,2 " %%A in ('wmic logicaldisk get caption^,VolumeName 2^>NUL') do ( IF /I "%%B"=="wim" SET wimdrive=%%A ) IF DEFINED wimdrive ECHO Lauferk "wim" wurde gefunden: %wimdrive% &&PAUSE&&GOTO :MENU ECHO Lauferk "wim" wurde nicht gefunden :( PAUSE GOTO :EOF :MENU CLS ECHO ============= Bitte auswaehlen ======================= ECHO ----------------- ECHO 1. Windows 7 64bit - 29.08.2016 ECHO ----------------- ECHO 2. Windows 7 64bit - AutoCAD ECHO ---------------- ECHO 3. Windows 10 LTSB - mit BIOS ECHO ---------------- ECHO 4. Windows 10 LTSB - mit UEFI ECHO ---------------- ECHO ==========Bitte druecken Sie Taste-Q zum Abbrechen========== ECHO. :Inputloop SET "Input=" SET /P "Input=Please Enter 1-4 or Q: " IF NOT DEFINED Input ECHO Invalid input & goto :Inputloop ::This limits the input to first character: SET "Input=!Input:~0,1!" ::This limits the input to characters in delims for /f "delims=1234qQ" %%? in ("!Input!") DO ECHO Invalid input & GOTO :Inputloop IF /I "%Input%"=="q" ECHO Batch stopped by user choice&&PAUSE&&GOTO :EOF ECHO Jetzt wird alles automatich gemacht (diskpart, imagex(dism), bcdboot)! CALL :Choice_%Input% ECHO Fertig. Bitte PC neu starten (exit befehl). ECHO ------------------ ECHO =============Druecken Sie belibiege Taste============== ECHO ------------------ GOTO :EOF :Choice_1 Diskpart /s %wimdrive%\mbr.txt %wimdrive%\Imagex.exe /apply %wimdrive%\win7_64bit_2016.wim 1 C: CD /D C:\Windows\SysWow64 bcdboot C:\Windows /s S: GOTO :EOF :Choice_2 Diskpart /s %wimdrive%\mbr.txt %wimdrive%\Imagex.exe /apply %wimdrive%\win7_64_autocad_07092016.wim 1 C: CD /D C:\Windows\SysWow64 bcdboot C:\Windows /s S: GOTO :EOF :Choice_3 Diskpart /s %wimdrive%\mbr.txt dism /Apply-Image /ImageFile:%wimdrive%\win10.wim /Index:1 /ApplyDir:C:\ CD /D C:\Windows\SysWow64 bcdboot C:\Windows /s S: /f ALL GOTO :EOF :Choice_4 Diskpart /s %wimdrive%\gpt.txt dism /Apply-Image /ImageFile:%wimdrive%\win10.wim /Index:1 /ApplyDir:W:\ CD /D W:\Windows\SysWow64 bcdboot W:\Windows /s S: /f ALL GOTO :EOF At first sight, you have seemingly 3 out of the 4 choices working when using the drive letter C: and 1 not working when you use drive letter W:. Now what it seems like missing/wrong/to be understood is how you assign drive letters (I believe that this happens in the Diskpart scripts mbr.txt and gpt.txt, which you should provide, later we will see if it is the case of embedding them in the batch) and how BEFORE running potentially destructive commands such as Diskpart and ImageX or Dism the status of drive letter assignments and of physicaldrives is checked. I mean, are all machines in the same EXACT configuration and do all the BIOSes/UEFIs behave the same? Is actually the internal disk the first disk (PhysicalDrive0) on all machines (even when booted from USB)? Is the disk always either "clean" or "partitioned"? Please post some details and the two diskpart scripts so that we can understand if this can be an issue. jaclaz 1 Link to comment Share on other sites More sharing options...
bingloverld Posted September 10, 2016 Author Share Posted September 10, 2016 Thank you. You have right should be "Laufwerk" Link to comment Share on other sites More sharing options...
bingloverld Posted September 10, 2016 Author Share Posted September 10, 2016 (edited) Thank you. You have right should be "Laufwerk" gpt.txt source file: select disk 0 clean convert gpt create partition primary size=300 format quick fs=ntfs label="Windows RE tools" assign letter="T" set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac" gpt attributes=0x8000000000000001 create partition efi size=100 format quick fs=fat32 label="System" assign letter="S" create partition msr size=128 create partition primary shrink minimum=15000 format quick fs=ntfs label="Windows" assign letter="W" create partition primary format quick fs=ntfs label="Recovery image" assign letter="R" set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac" gpt attributes=0x8000000000000001 list volume exit When I write befhel diskpart /s gpt.txt it woks and I can manually apply my image on W: drive. 1. I mean, are all machines in the same EXACT configuration and do all the BIOSes/UEFIs behave the same? 2. Is actually the internal disk the first disk (PhysicalDrive0) on all machines (even when booted from USB)? 3. Is the disk always either "clean" or "partitioned"? 1. We are using only HP PCs and Laptops. What I saw they all behave the same. 2. Yes, I have not saw that PC or Laptop with intern HDD/SSD was other than disk 0 3. Yes, we clean alway disk, and then we are making partitions. By gpt you must use "convert gpt" command next to "clean disk" Edited September 10, 2016 by bingloverld Link to comment Share on other sites More sharing options...
jaclaz Posted September 10, 2016 Share Posted September 10, 2016 Hmmm. It could be a timing problem, but since after you create the "main" partition and assign to it the "W" drive letter you create another partition that shouldn't be the issue. And after all the gpt.txt seems like being taken (almost verbatim) from the MSDN one: https://msdn.microsoft.com/en-us/library/windows/hardware/dn621890.aspx What happens if you add a check after the gpt.txt is run? Quote :Choice_4 Diskpart /s %wimdrive%\gpt.txt SET windowsdrive= FOR /F "tokens=1,2 " %%A in ('wmic logicaldisk get caption^,VolumeName 2^>NUL') do ( IF /I "%%B"=="Windows" SET windowsdrive=%%A ) IF DEFINED windowsdrive ECHO Laufwerk "windows" wurde gefunden: %windowsdrive% &&PAUSE&&GOTO :do_dism ECHO Laufwerk "windows" wurde nicht gefunden ECHO Stopping execution ... PAUSE GOTO :EOF :do_dism dism /Apply-Image /ImageFile:%wimdrive%\win10.wim /Index:1 /ApplyDir:W:\ CD /D W:\Windows\SysWow64 bcdboot W:\Windows /s S: /f ALL GOTO :EOF Still downright selecting disk 0 may be a risk in some configurations... and there is not much sense in creating the WinRE and Recovery partition if you don't use them. jaclaz Link to comment Share on other sites More sharing options...
bingloverld Posted September 10, 2016 Author Share Posted September 10, 2016 (edited) Yes I tooked gpt recommendations directly from Microsoft, gpt.txt is 100% copy/paste. Is this not important for UEFI? But you have right we don't use them. Do you have antoher idea for select disk 0 (we don't use RAID systems also on CAD-Workstations etc. It is always one hard drive/SSD system) ? When I run modified :Choice_4 it works! Edited September 10, 2016 by bingloverld Link to comment Share on other sites More sharing options...
jaclaz Posted September 10, 2016 Share Posted September 10, 2016 10 minutes ago, bingloverld said: Is this not important for UEFI? But you have right we don't use them. Naah, it is just a "guideline" for OEM's. While there might be some relevance in having the WinRE partition (of course only if actually working/populated by the WinRE.wim) the recovery partition makes little sense on desktops (managed, in a commercial environment), it is designed/suited for OEM laptops and tablets. The MSR partition as well makes little sense, it has yet to be proved/tested/reported that has ANY use if not in case of resizing partitions (which you won't likely do) and even in that case, allow me to doubt that it is actually *needed*. My guess is that they are trying to show off a little bit and make use of the GPT partitioning scheme that allows for unlimited volumes[1] all primary. All that is needed is a "System" and a "Boot" volume (which the good MS guys call the other way round), respectively the W: and S: in your gpt.txt if called "rightly" or S: and W: using the MS terminology. 17 minutes ago, bingloverld said: Do you have antoher idea for select disk 0? I will think of something though usually coupling physicaldrives with volumes/drive letters is a PITA. 22 minutes ago, bingloverld said: When I run modified :Choice_4 it works! Which should mean that it is a timing issue of some kind, maybe the shrinking of the W: partition? Try removing from gpt.txt the lines that shrink the "main" volume and create the additional (unused) recovery partition: select disk 0 clean convert gpt create partition primary size=300 format quick fs=ntfs label="Windows RE tools" assign letter="T" set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac" gpt attributes=0x8000000000000001 create partition efi size=100 format quick fs=fat32 label="System" assign letter="S" create partition msr size=128 create partition primary format quick fs=ntfs label="Windows" assign letter="W" list volume exit and try it with the previous (without the check) batch. jaclaz [1] "unlimited" as in "max 128 partitions" 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