Invoke-WPFMicrowin : An unexpected error occurred: No se puede indizar en una matriz nula.
Describe the bug When using a spanish mexico windows 11 iso this error shows after removing bloat:
Mounting complete! Performing removal of applications...
Remove Features from the image
Removing features complete!
Removing Appx Bloat
Invoke-WPFMicrowin : An unexpected error occurred: No se puede indizar en una matriz nula.
En línea: 2005 Carácter: 24
+ "WPFMicrowin" {Invoke-WPFMicrowin}
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-WPFMicrowin
Unmounting Registry...
ERROR: El parámetro no es correcto.
ERROR: El parámetro no es correcto.
ERROR: El parámetro no es correcto.
ERROR: El parámetro no es correcto.
ERROR: El parámetro no es correcto.
Cleaning up image...
Cleanup complete.
To Reproduce Steps to reproduce the behavior:
- Go to MicroWin tab
- Check download oscdimg.exe from ctt github repo
- Click on select windows iso and select an spanish mexico windows 11 iso
- Select windows 11 pro and keep windows defender and microsoft edge
- Start the microwin debloat
- The error will show
Expected behavior No error code should appear
Screenshots
Additional context I'm doing the process on a SteamDeck running windows 10 iot ltsc
It is most likely due to localization. Some chars are not being passed correctly to dism? There is also oscdimg problem that I see on your system. I think Cris added a wrong hash number. I don't have the time to dig into this, maybe @CodingWonders could help?
It is most likely due to localization. Some chars are not being passed correctly to dism? There is also oscdimg problem that I see on your system. I think Cris added a wrong hash number. I don't have the time to dig into this, maybe @CodingWonders could help?
I most definitely have a different SHA256 for oscdimg.exe, so I feel like this could be a dynamic issue. I don't know that I would expect the hash to ALWAYS be the same on installs over periods of time.
Is hard coding the hash a viable option here? I'm leaning towards no.
@munkk01 hash should be always the same it is an exe (binary file) that should not be changed. If it is changing, there is something wrong. I noticed that Chris check it into the source control as a source file. This is not how I intended it to work. I intended for him to put it into Release section not source control. I've tested it extensively, with Release and it worked fine. I'm not saying that checking it into source causes this issue, but I know putting it into Release didn't cause this issue.
@munkk01 hash should be always the same it is an exe (binary file) that should not be changed. If it is changing, there is something wrong. I noticed that Chris check it into the source control as a source file. This is not how I intended it to work. I intended for him to put it into Release section not source control. I've tested it extensively, with Release and it worked fine. I'm not saying that checking it into source causes this issue, but I know putting it into Release didn't cause this issue.
Well for reference:
Hash value in the utility at the moment
Hash value from a 23H2 machine in a vm I run
->
Additionally, peep the relationships to this hash:
It is 100% plausible for the hashes to vary as it's a compiled program. So any changes made by Microsoft and re-compiled would result in something like this, no?
EDIT:
The SHA256 of oscdimg from https://github.com/ChrisTitusTech/winutil/raw/main/releases/oscdimg.exe is ab9e161049d293b544961bfdf2d61244ade79376d6423df4f60bf9b147d3c78d
In Get-Oscdimg.ps1 the hard coded SHA256 is F62B91A06F94019A878DD9D1713FFBA2140B863C131EB78A329B4CCD6102960E which doesn't match the hash of the oscdimg in the release URL you have.
It is 100% plausible for the hashes to vary as it's a compiled program. So any changes made by Microsoft and re-compiled would result in something like this, no?
@munkk01 That's obvious, 👍 but only if someone updates the exe. The purpose of this hash check was to - check in a specific version of oscdimg.exe file that was checked by antivirus to a place where only Chris can change the file and no one else, which means "if you trust Chris you trust the app" This is to put a certain category of people that were for example complaining about this file in tiny11 script. When I check it my version I downloaded the latest version of this file from the latest ADK https://learn.microsoft.com/en-us/windows-hardware/get-started/adk-install and updated set the hash value for that file. Chris checked in his oscdimg (I have no idea where he got it) but he might have forgotten to update the hash or the hash as you say changing somehow, but it is very unlikely. Also foe extra paranoid crowd I left the option to download full blown ADK, which happens if you don't check the checkbox for github download.
Anyway it seems that @juliocoliveira updated the hash (https://github.com/ChrisTitusTech/winutil/pull/1301/commits/063c08c99c5b7161d6d7a3d8a0804734f4cb53b3) awhile back but it got reverted for some reason
It is most likely due to localization. Some chars are not being passed correctly to dism? There is also oscdimg problem that I see on your system. I think Cris added a wrong hash number. I don't have the time to dig into this, maybe @CodingWonders could help?
My guess is that Get-AppxProvisionedPackage is failing and thus the array isn't being initialized.
Looking at the code, I can see that it doesn't detect whether a command quit successfully.
This can easily be done with PS by using the $? variable, like this:
if ($?)
{
# Success
}
else
{
# Failure
}
When can one expect those changes to go to main? I'm having the same issues.
It is 100% plausible for the hashes to vary as it's a compiled program. So any changes made by Microsoft and re-compiled would result in something like this, no?
@munkk01 That's obvious, 👍 but only if someone updates the exe. The purpose of this hash check was to - check in a specific version of oscdimg.exe file that was checked by antivirus to a place where only Chris can change the file and no one else, which means "if you trust Chris you trust the app" This is to put a certain category of people that were for example complaining about this file in tiny11 script. When I check it my version I downloaded the latest version of this file from the latest ADK https://learn.microsoft.com/en-us/windows-hardware/get-started/adk-install and updated set the hash value for that file. Chris checked in his oscdimg (I have no idea where he got it) but he might have forgotten to update the hash or the hash as you say changing somehow, but it is very unlikely. Also foe extra paranoid crowd I left the option to download full blown ADK, which happens if you don't check the checkbox for github download.
Anyway it seems that @juliocoliveira updated the hash (https://github.com/ChrisTitusTech/winutil/pull/1301/commits/063c08c99c5b7161d6d7a3d8a0804734f4cb53b3) awhile back but it got reverted for some reason
My commit didn't got reverted, but it was merged in other branch than the main, I guess @ChrisTitusTech will merge the branches live on Tuesday, that is my guess
Hello, I'm having the same issue using version 24.01.03 on a localized German Windows 10.
I debugged it and it's related to the "function Get-LocalizedYesNo". On my system the function returns an empty array/value and not "J" for Ja (= Yes).
As a reference here's the output of the command "takeown.exe /?" which is parsed in this function:
Edit: I did further debugging with an English (US) installation of Windows 10.
"Takeown.exe /?" lists the "Yes and No" values of the "/D" option in one line. In the German verion the values "Ja" and "Nein" are listed in two separate lines.
I hope that helps.
Oh man this has been a problem since day 1, this localization issue in Windows is a nightmare. We need a better way to get localized "J" for each language. What is frustrating is that in soem locals like Russian and Japanese for example it is still "Y" and "N" but other's Like German and Spanish it is localized.
@KonTy: This is my first contribution to an OSS project and I'm even not familiar with github, so please bear with me if this is the wrong way to go about it.
The problem should be that in the description of the option "/D" the two values for Yes and No are in one line (English version but also for example in the Dutch version). And in some localized versions the values are in two different lines (German, French, Spanish). I have tested these language versions and they all worked.
For me, this solution was successful: Using a second temporary array ($charactersArrayTemp) filled with the values from the two-line outputs. First the value for Yes, then the value for No. It's probably not the nicest solution, but it works in the Windows versions mentioned above.
The modified function:
function Get-LocalizedYesNo {
<#
.SYNOPSIS
This function runs takeown.exe and captures its output to extract yes no in a localized Windows
.DESCRIPTION
The function retrieves lines from the output of takeown.exe until there are at least 2 characters
captured in a specific format, such as "Yes=<first character>, No=<second character>".
.EXAMPLE
$yesNoArray = Get-LocalizedYesNo
Write-Host "Yes=$($yesNoArray[0]), No=$($yesNoArray[1])"
#>
# Run takeown.exe and capture its output
$takeownOutput = & takeown.exe /? | Out-String
# Parse the output and retrieve lines until there are at least 2 characters in the array
$found = $false
$charactersArray = @()
# temporary second array
$charactersArrayTemp = @()
foreach ($line in $takeownOutput -split "`r`n")
{
# skip everything before /D flag help
if ($found)
{
# now that /D is found start looking for a single character in double quotes
# in help text there is another string in double quotes but it is not a single character
$regexPattern = '"([a-zA-Z])"'
$charactersArray = [regex]::Matches($line, $regexPattern) | ForEach-Object { $_.Groups[1].Value }
# If yes and No are in different $line(s) a temporary array is filled with both
if ($charactersArray.Count -gt 0) {
$charactersArrayTemp += [regex]::Matches($line, $regexPattern) | ForEach-Object { $_.Groups[1].Value }
}
# When both values for Yes and No are collected the array to be returned is filled with the temporary array
if ($charactersArrayTemp.count -ge 2) {
$charactersArray = $charactersArrayTemp
break
}
# if ($charactersArray.Count -gt 0) {
# Write-Output "Extracted symbols: $($matches -join ', ')"
# } else {
# Write-Output "No matches found."
# }
# Yes and No in the same $line
if ($charactersArray.Count -ge 2)
{
break
}
}
elseif ($line -match "/D ")
{
$found = $true
}
}
Write-Debug "According to takeown.exe local Yes is $charactersArray[0]"
# Return the array of characters
return $charactersArray
}
Another solution may be the powershell command Set-Acl instead of using takeown.exe but this would need more modifications to the scipt.
@dtm-r thank you very much for such in depth investigation. I can fold your code into the project so everyone could test it, unless you want to raise the PR yourself.
As far as set-Acl I have tried that it didn't work, I don't remember the details but there were some major problems with it and I didn't have time to dig in. There is apparently another way of getting "Y" "N" letters by using choice.exe utility but again I didn't have time to investigate it. Like here in this post if you have time to play with this let me know.
@KonTy: As I have written, I'm not familiar with github, cloning a repo, pull requests etc. So, please add the code to the project for testing.
And I have looked into the solution using choice.exe you've mentioned.
This would be the modified function. I've tested with English, German, Dutch, French, Italian, Spansich and Russian localized versions. It looks somehow promising:
function Get-LocalizedYesNo {
<#
.SYNOPSIS
This function runs choice.exe and captures its output to extract yes no in a localized Windows
.DESCRIPTION
The function retrieves the output of the command 'cmd /c "choice <nul 2>nul"' and converts the default output for Yes and No
in the localized format, such as "Yes=<first character>, No=<second character>".
.EXAMPLE
$yesNoArray = Get-LocalizedYesNo
Write-Host "Yes=$($yesNoArray[0]), No=$($yesNoArray[1])"
#>
# Run choice and capture its options as output
# The output shows the options for Yes and No as "[Y,N]?" in the (partitially) localized format.
# eg. English: [Y,N]?
# Dutch: [Y,N]?
# German: [J,N]?
# French: [O,N]?
# Spanish: [S,N]?
# Italian: [S,N]?
# Russian: [Y,N]?
$line = cmd /c "choice <nul 2>nul"
$charactersArray = @()
$regexPattern = '([a-zA-Z])'
$charactersArray = [regex]::Matches($line, $regexPattern) | ForEach-Object { $_.Groups[1].Value }
Write-Debug "According to takeown.exe local Yes is $charactersArray[0]"
# Return the array of characters
return $charactersArray
}
@dtm-r wow man you are awesome, see people like you move OpenSource projects forward. Thank you very much for doing this AND testing it on many languages. I should probably also download whole bunch of ISOs like you did. This would improve the quality of this tool if we tested several languages like you did. Are you using VirtualBox or some other vm solution to test?
PS I tested it in Japanese it was also Y,N do you have a Chinese image, I wonder what it would be. Also does choice.exe beep for you when you run it? It beeps at me which is a little annoying. :)
@dtm-r ok your change is now live in my branch you can test it if you want
iwr -useb https://raw.githubusercontent.com/KonTy/winutil/LinksAndPerf/winutil.ps1 | iex
@KonTy: I've used the MUI functionality of Windows 10 pro for testing the different languages. This works like charm since Win 7. In Chinese (simplified) the options are Y and N, too.
Your branch does work for me, no more error in MicroWin. And on Win 10 Pro (DE) it doesn't beep, neither in Powershell ISE nor in Powershell. Haven't tried the Terminal app.
Hello @KonTy Please i have this error i can't create my custom iso (new iso download from microsoft official website). Can u help me
The 80041031 error code typically indicates an issue related to Windows Management Instrumentation (WMI). Here are a few steps you can try to resolve the issue:
-
Reboot Your Computer: Sometimes, a simple reboot can resolve temporary issues. Restart your computer and try mounting the ISO again.
-
Check for System Corruption: Run the System File Checker (SFC) utility to scan and repair system files that may be corrupted.
sfc /scannow -
Update Your System: Make sure your operating system is up-to-date. Check for Windows updates and install any pending updates.
-
Check WMI Service: Ensure that the Windows Management Instrumentation (WMI) service is running. You can do this through the Services application:
- Press
Win + Rto open the Run dialog. - Type
services.mscand press Enter. - Locate "Windows Management Instrumentation" in the list.
- Make sure its status is set to "Running" and the startup type is set to "Automatic."
- Press
-
Check for Security Software Interference: Security software can sometimes interfere with WMI operations. Temporarily disable your antivirus or security software and check if the issue persists.
-
Event Viewer: Check the Event Viewer for more detailed error information. Look for entries related to the
80041031error and check if there are any additional details that can help identify the cause.- Press
Win + Xand select "Event Viewer." - Navigate to "Windows Logs" -> "Application" or "System."
- Look for entries with the source related to WMI or the application you're using to mount the ISO.
- Press
-
ISO File Integrity: Ensure that the ISO file you are trying to mount is not corrupted. Try mounting a different ISO file to see if the issue persists.
If the problem persists after trying these steps, additional troubleshooting may be required. Consider seeking assistance from Microsoft support or community forums for more specific guidance based on your system configuration and the software you are using to mount the ISO.
Hello, I am still having the same error
How to replicate:
Download oscdimg.exe, tried with both checked and unchecked, still same problem Only keep defender is checked in both attempts. ISO file is latest windows 11 iso from official microsoft website, Pro version chosen in microwin
Closed due to inactivity