MHimken / WinRE-Customization

WinRE Customization to apply patches, drivers and soon™ language packs
https://manima.de/2023/01/modify-winre-patches-drivers-and-cve-2022-41099/
MIT License
61 stars 8 forks source link

script errors out if WinRE.wim is not in System32 but is in a hidden recovery partition instead #4

Closed encip closed 1 year ago

encip commented 1 year ago

I get the following error when running the script:

Copy-Item : Cannot find path 'C:\Windows\System32\Recovery\WinRE.wim' because it does not exist.
At C:\bitlocker-winre-fix.ps1:399 char:5
+     Copy-Item -Path $WinREDefaultLocation -Destination $BackupDirecto ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Windows\System32\Recovery\WinRE.wim:String) [Copy-Item], ItemNotFoun
   dException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand

Output of reagentc /info

C:\windows\system32>reagentc /info
Windows Recovery Environment (Windows RE) and system reset configuration
Information:

    Windows RE status:         Enabled
    Windows RE location:       \\?\GLOBALROOT\device\harddisk0\partition1\Recovery\WindowsRE
    Boot Configuration Data (BCD) identifier: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    Recovery image location:
    Recovery image index:      0
    Custom image location:
    Custom image index:        0

REAGENTC.EXE: Operation Successful.
MHimken commented 1 year ago

Hey @encip can you share the parameters you used to run the script, OS Version and language/system language used please? The following will give you the information required. Get-UICulture Get-Culture Get-CimInstance -ClassName Win32_OperatingSystem | select Version

If possible, please attach the log the script created as well.

encip commented 1 year ago
PS C:\> Get-UICulture

LCID             Name             DisplayName
----             ----             -----------
1033             en-US            English (United States)

PS C:\> Get-Culture

LCID             Name             DisplayName
----             ----             -----------
1033             en-US            English (United States)

PS C:\> Get-CimInstance -ClassName Win32_OperatingSystem | select Version

Version
-------
10.0.19045
PS C:\> .\bitlocker-winre-fix
Resolve-Path : Cannot find path 'C:\Windows\System32\Recovery\WinRE.wim' because it does not exist.
At
C:\windows\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psm1:110
char:36
+                 $pathsToProcess += Resolve-Path $Path | Foreach-Objec ...
+                                    ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Windows\System32\Recovery\WinRE.wim:String) [Resolve-Path], ItemNotF
   oundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.ResolvePathCommand

Copy-Item : Cannot find path 'C:\Windows\System32\Recovery\WinRE.wim' because it does not exist.
At C:\bitlocker-winre-fix.ps1:399 char:5
+     Copy-Item -Path $WinREDefaultLocation -Destination $BackupDirecto ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Windows\System32\Recovery\WinRE.wim:String) [Copy-Item], ItemNotFoun
   dException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand
MHimken commented 1 year ago

That seems to be exactly what I used for testing as well - please try to run reagentc /disable and see if that works without error. After that, navigate to \Windows\System32\Recovery\ and check if the WinRE.wim file exists. You need to enable "Show Hidden System Files" and "Show Hidden Files" otherwise you won't be able to see the file. There is (to my knowledge) no way that if the /disable worked, that the .wim file shouldn't be in that folder.

Your "Resolve-Path $Path" error is also weird - please try looking into that as well. Make sure it doesn't happen on just one PC as well. If you have any kind of Third-Party AV installed, please make sure it doesn't interfere.

Regards Martin

MHimken commented 1 year ago

Hey @encip did you have a chance to try my suggestions yet?

Regards Martin

MHimken commented 1 year ago

Unfortunately no further response. If you can provide me with more details I'll gladly try to fix any issues.