ChrisTitusTech / winutil

Chris Titus Tech's Windows Utility - Install Programs, Tweaks, Fixes, and Updates
MIT License
20.68k stars 1.28k forks source link

Microwin Generates Error on Scratch ISO misuse. #1591

Closed MichTheOcelot closed 7 months ago

MichTheOcelot commented 7 months ago

Describe the bug Using a Win11_23H2_English_x64v2 ISO in microwin on the latest version with defaults (Keep Defender and Edge ticked) will generate an error and ignore Copy to Ventoy, leaving the final file on the desktop. To Reproduce Steps to reproduce the behavior:

  1. Get the official Win11_23H2_English_x64v2 ISO from the microsoft page.
  2. Insert on microwin as usual
  3. Select your SKU and start the process
  4. See error:
    
    Invoke-WPFMicrowin : An unexpected error occurred: Cannot rename the specified target, because it represents a path or
    device name.
    At line:2421 char:24
    +         "WPFMicrowin" {Invoke-WPFMicrowin}
    +                        ~~~~~~~~~~~~~~~~~~
     CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
     FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-WPFMicrowin

Unmounting Registry... ERROR: The parameter is incorrect. ERROR: The parameter is incorrect. ERROR: The parameter is incorrect. ERROR: The parameter is incorrect. ERROR: The parameter is incorrect. Unmounting image... Creating ISO image [INFO] Using oscdimg.exe from: oscdimg.exe Copying target ISO to the USB drive Ventoy USB Key is not inserted Done Copying target ISO to USB drive!


(_ \ \ \ _ | | | / | \ / _ ) | |/ / |_| | | | ( (/ / |___/ _/|| ||__) ISO creation failed. The win11\micro directory has not been removed


**Expected behavior**
The debloated iso is made with no issues and inside the specified directory.

**Screenshots**
If applicable, add screenshots to help explain your problem.
![powershell_JaAj2WaMoT](https://github.com/ChrisTitusTech/winutil/assets/154266029/9517052b-782e-4f0b-a7f0-350aac42a05d)

**Additional context**
Add any other context about the problem here.
MichTheOcelot commented 7 months ago

Nevermind, this happens due to misuse of the "Scratch Dir" toggle. Would be great to know what it does, apologies for this issue, does remind me of #1353 but has been solved for a while.

CodingWonders commented 7 months ago

I don't really know what this option does either, but I guess ISO files are copied to that custom folder instead of the default directory in %TEMP%.

Now, @MichTheOcelot, how did you "misuse" the ScratchDir option the first time?

MichTheOcelot commented 7 months ago

@CodingWonders Yes, that seems to be the intended use... i thought it would let me choose the sku before having to mount the ISO foolishly- i have been able to reproduce the error with the following actions:

  1. Insert ISO on microwin
  2. I selected my downloads folder for scratchdir and ticked the option.
  3. Select your SKU, and tick the copy to ventoy option into the same downloads folder, i named my iso to be "qwerty"
  4. See log: Weirdly enough it is not the same thing that happened on my initial report, since it did prompt me to where the iso location was and also was able to finish the process, but this time it skipped the entire debloating steps... so instead of failing at the registry modification step it just fails here, still running with defaults (edge and defender on)
CCCCCCCCCCCCCTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
 CCC::::::::::::CT:::::::::::::::::::::TT:::::::::::::::::::::T                                                         CC:::::::::::::::CT:::::::::::::::::::::TT:::::::::::::::::::::T                                                        C:::::CCCCCCCC::::CT:::::TT:::::::TT:::::TT:::::TT:::::::TT:::::T                                                       C:::::C       CCCCCCTTTTTT  T:::::T  TTTTTTTTTTTT  T:::::T  TTTTTT                                                      C:::::C                     T:::::T                T:::::T                                                              C:::::C                     T:::::T                T:::::T
C:::::C                     T:::::T                T:::::T
C:::::C                     T:::::T                T:::::T
C:::::C                     T:::::T                T:::::T                                                              C:::::C                     T:::::T                T:::::T                                                              C:::::C       CCCCCC        T:::::T                T:::::T                                                              C:::::CCCCCCCC::::C      TT:::::::TT            TT:::::::TT                                                             CC:::::::::::::::C       T:::::::::T            T:::::::::T                                                             CCC::::::::::::C         T:::::::::T            T:::::::::T                                                               CCCCCCCCCCCCC          TTTTTTTTTTT            TTTTTTTTTTT
====Chris Titus Tech=====
=====Windows Toolbox=====
Checking if Chocolatey is Installed...
Chocolatey Already Installed
No ISO is chosen+  D:\Downloads
No ISO is chosen+  D:\Downloads\
No ISO is chosen+  win11
Invoking WPFGetIso
         _                     __    __  _
  /\/\  (_)  ___  _ __   ___  / / /\ \ \(_) _ __
 /    \ | | / __|| '__| / _ \ \ \/  \/ /| || '_ \
/ /\/\ \| || (__ | |   | (_) | \  /\  / | || | | |
\/    \/|_| \___||_|    \___/   \/  \/  |_||_| |_|
oscdimg.exe on system: True
File path D:\Downloads\Win11_23H2_English_x64v2.iso
Mounting Iso. Please wait.
Done mounting Iso MSFT_DiskImage (ImagePath = "D:\Downloads\Win11_23H2_English_x64v2.i..., StorageType = 1)
Iso mounted to 'E'
Setting up mount dir and scratch dirs
Mounting Iso. Please wait.
Done setting up mount dir and scratch dirs
Scratch dir is D:\Downloads\Scrach
Image dir is D:\Downloads\micro
Copying Windows image. This will take awhile, please don't use UI or cancel this step!
Copy 1031(s) from E: to D:\Downloads\micro
Copy complete! Total Time: 0m10s
Getting image information D:\Downloads\micro\sources\install.wim
Finding suitable Pro edition. This can take some time. Do note that this is an automatic process that might not select the edition you want.
Selected value '6 : Windows 11 Pro'.....
Done reading and unpacking ISO

*********************************
Check the UI for further steps!!!
Target ISO location: D:\Downloads\qwerty.iso
Index chosen: '6' from 6 : Windows 11 Pro
Mounting Windows image. This may take a while.
Mounting complete! Performing removal of applications...
Remove Features from the image
Removing features complete!
Removing Appx Bloat
Invoke-WPFMicrowin : An unexpected error occurred: The specified module could not be found.
At line:2421 char:24
+         "WPFMicrowin" {Invoke-WPFMicrowin}
+                        ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-WPFMicrowin

Unmounting Registry...
ERROR: The parameter is incorrect.
ERROR: The parameter is incorrect.
ERROR: The parameter is incorrect.
ERROR: The parameter is incorrect.
ERROR: The parameter is incorrect.
Cleaning up image...
Cleanup complete.
Unmounting image...
Exporting image into D:\Downloads\micro\sources\install2.wim
Remove old 'D:\Downloads\micro\sources\install.wim' and rename D:\Downloads\micro\sources\install2.wim
Windows image completed. Continuing with boot.wim.
Mounting boot image D:\Downloads\micro\sources\boot.wim into D:\Downloads\Scrach
Loading registry...
Bypassing system requirements on the setup image
Unmounting Registry...
Unmounting image...
Creating ISO image
[INFO] Using oscdimg.exe from: oscdimg.exe
Copying target ISO to the USB drive
Ventoy USB Key is not inserted
Done Copying target ISO to USB drive!
 _____
(____ \
 _   \ \ ___  ____   ____
| |   | / _ \|  _ \ / _  )
| |__/ / |_| | | | ( (/ /
|_____/ \___/|_| |_|\____)

Performing Cleanup...
Done. ISO image is located here: D:\Downloads\qwerty.iso
CodingWonders commented 7 months ago

@CodingWonders Yes, that seems to be the intended use... i thought it would let me choose the sku before having to mount the ISO foolishly- i have been able to reproduce the error with the following actions:

  1. Insert ISO on microwin
  2. I selected my downloads folder for scratchdir and ticked the option.
  3. Select your SKU, and tick the copy to ventoy option into the same downloads folder, i named my iso to be "qwerty"
  4. See log: Weirdly enough it is not the same thing that happened on my initial report, since it did prompt me to where the iso location was and also was able to finish the process, but this time it skipped the entire debloating steps... so instead of failing at the registry modification step it just fails here, still running with defaults (edge and defender on)
CCCCCCCCCCCCCTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
 CCC::::::::::::CT:::::::::::::::::::::TT:::::::::::::::::::::T                                                         CC:::::::::::::::CT:::::::::::::::::::::TT:::::::::::::::::::::T                                                        C:::::CCCCCCCC::::CT:::::TT:::::::TT:::::TT:::::TT:::::::TT:::::T                                                       C:::::C       CCCCCCTTTTTT  T:::::T  TTTTTTTTTTTT  T:::::T  TTTTTT                                                      C:::::C                     T:::::T                T:::::T                                                              C:::::C                     T:::::T                T:::::T
C:::::C                     T:::::T                T:::::T
C:::::C                     T:::::T                T:::::T
C:::::C                     T:::::T                T:::::T                                                              C:::::C                     T:::::T                T:::::T                                                              C:::::C       CCCCCC        T:::::T                T:::::T                                                              C:::::CCCCCCCC::::C      TT:::::::TT            TT:::::::TT                                                             CC:::::::::::::::C       T:::::::::T            T:::::::::T                                                             CCC::::::::::::C         T:::::::::T            T:::::::::T                                                               CCCCCCCCCCCCC          TTTTTTTTTTT            TTTTTTTTTTT
====Chris Titus Tech=====
=====Windows Toolbox=====
Checking if Chocolatey is Installed...
Chocolatey Already Installed
No ISO is chosen+  D:\Downloads
No ISO is chosen+  D:\Downloads\
No ISO is chosen+  win11
Invoking WPFGetIso
         _                     __    __  _
  /\/\  (_)  ___  _ __   ___  / / /\ \ \(_) _ __
 /    \ | | / __|| '__| / _ \ \ \/  \/ /| || '_ \
/ /\/\ \| || (__ | |   | (_) | \  /\  / | || | | |
\/    \/|_| \___||_|    \___/   \/  \/  |_||_| |_|
oscdimg.exe on system: True
File path D:\Downloads\Win11_23H2_English_x64v2.iso
Mounting Iso. Please wait.
Done mounting Iso MSFT_DiskImage (ImagePath = "D:\Downloads\Win11_23H2_English_x64v2.i..., StorageType = 1)
Iso mounted to 'E'
Setting up mount dir and scratch dirs
Mounting Iso. Please wait.
Done setting up mount dir and scratch dirs
Scratch dir is D:\Downloads\Scrach
Image dir is D:\Downloads\micro
Copying Windows image. This will take awhile, please don't use UI or cancel this step!
Copy 1031(s) from E: to D:\Downloads\micro
Copy complete! Total Time: 0m10s
Getting image information D:\Downloads\micro\sources\install.wim
Finding suitable Pro edition. This can take some time. Do note that this is an automatic process that might not select the edition you want.
Selected value '6 : Windows 11 Pro'.....
Done reading and unpacking ISO

*********************************
Check the UI for further steps!!!
Target ISO location: D:\Downloads\qwerty.iso
Index chosen: '6' from 6 : Windows 11 Pro
Mounting Windows image. This may take a while.
Mounting complete! Performing removal of applications...
Remove Features from the image
Removing features complete!
Removing Appx Bloat
Invoke-WPFMicrowin : An unexpected error occurred: The specified module could not be found.
At line:2421 char:24
+         "WPFMicrowin" {Invoke-WPFMicrowin}
+                        ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-WPFMicrowin

Unmounting Registry...
ERROR: The parameter is incorrect.
ERROR: The parameter is incorrect.
ERROR: The parameter is incorrect.
ERROR: The parameter is incorrect.
ERROR: The parameter is incorrect.
Cleaning up image...
Cleanup complete.
Unmounting image...
Exporting image into D:\Downloads\micro\sources\install2.wim
Remove old 'D:\Downloads\micro\sources\install.wim' and rename D:\Downloads\micro\sources\install2.wim
Windows image completed. Continuing with boot.wim.
Mounting boot image D:\Downloads\micro\sources\boot.wim into D:\Downloads\Scrach
Loading registry...
Bypassing system requirements on the setup image
Unmounting Registry...
Unmounting image...
Creating ISO image
[INFO] Using oscdimg.exe from: oscdimg.exe
Copying target ISO to the USB drive
Ventoy USB Key is not inserted
Done Copying target ISO to USB drive!
 _____
(____ \
 _   \ \ ___  ____   ____
| |   | / _ \|  _ \ / _  )
| |__/ / |_| | | | ( (/ /
|_____/ \___/|_| |_|\____)

Performing Cleanup...
Done. ISO image is located here: D:\Downloads\qwerty.iso

Yeah, but the problem is that, since the script is compiled after making a change, PowerShell doesn't do a great job at displaying errors in a function. I'll have to figure out where the code is failing based on what is output to the command window and update either Invoke-WPFMicrowin.ps1 or the MicroWin helper accordingly.