farag2 / Sophia-Script-for-Windows

:zap: The most powerful PowerShell module for fine-tuning Windows
MIT License
7.8k stars 579 forks source link

[WinAPI.GetStr]::GetString() RuntimeException #543

Closed lucasgruembel closed 1 year ago

lucasgruembel commented 1 year ago

Prerequisites

Steps to reproduce

Hello,

When executing some Sophia functions, the following error occurs:

Der Typ [WinAPI.GetStr] wurde nicht gefunden.
In C:\Users\User\Desktop\microsoft-windows_prepare-fresh-install\windows-11\Module\Sophia.psm1:10927 Zeichen:32
+     $TextBlockSelectAll.Text    = [WinAPI.GetStr]::GetString(31276)
+                                   ~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (WinAPI.GetStr:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

Der Typ [WinAPI.GetStr] wurde nicht gefunden.
In C:\Users\User\Desktop\microsoft-windows_prepare-fresh-install\windows-11\Module\Sophia.psm1:10949 Zeichen:27
+         Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -V ...
+                                 ~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (WinAPI.GetStr:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

Der Typ [WinAPI.GetStr] wurde nicht gefunden.
In C:\Users\User\Desktop\microsoft-windows_prepare-fresh-install\windows-11\Module\Sophia.psm1:15337 Zeichen:26
+     Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbo ...
+                             ~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (WinAPI.GetStr:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

The error occurs under Windows 10 Pro 22H2 (Build 19045.3636), Windows 11 Pro 22H2 (Build 22621.2506) and Windows 11 Pro 23H2 (Build 22631.2428) with Powershell 5. The systems were each freshly installed with the latest German 64-bit ISO from the Microsoft website.

Windows Version

Windows 11 Pro 23H2 (Build 22631.2428), Windows 11 Pro 22H2 (Build 22621.2506)

Sophia Script version

6.5.7 Powershell 5

farag2 commented 1 year ago

You excluded InitialActions function.

farag2 commented 1 year ago

https://github.com/farag2/Sophia-Script-for-Windows/blob/048c472448610f499f592b5f1d30429685336bba/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1#L118

lucasgruembel commented 1 year ago

Thanks, sorry, my mistake. I executed the InitialActions in advance under a parent powershell process. I overlooked the corresponding code in InitialActions. https://github.com/farag2/Sophia-Script-for-Windows/blob/048c472448610f499f592b5f1d30429685336bba/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1#L84

farag2 commented 1 year ago

Nobody's perfect))