Skip to content

Commit 33a8d90

Browse files
authored
Merge pull request #103 from mlipok/patch-1
Register_web2.au3 - RegRead fix + log
2 parents d52be4d + 7acce66 commit 33a8d90

1 file changed

Lines changed: 36 additions & 24 deletions

File tree

bin/Register_web2.au3

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Func _Register()
1919
Local $sNet4_x64 = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe"
2020

2121
Local $bSuccess = False
22+
Local $bAbort = False
2223
Local $sLog = "Registration Report:" & @CRLF & "--------------------" & @CRLF
2324

2425
; === Check for WebView2 Runtime ===
@@ -51,50 +52,59 @@ Func _Register()
5152
Else
5253
$sLog &= "[!] User skipped WebView2 installation. Aborting." & @CRLF
5354
MsgBox($MB_ICONSTOP, "Aborted", "Registration cannot continue without WebView2 Runtime.")
54-
Exit ; Stop the script
55+
$bAbort = True
5556
EndIf
5657
EndIf
5758

58-
; === Registration 'NetWebView2Lib.dll' COM ===
59-
Local $iExitCode
60-
61-
; Registration for x86 (32-bit)
62-
If FileExists($sNet4_x86) Then
63-
$iExitCode = RunWait('"' & $sNet4_x86 & '" "' & @ScriptDir & '\' & $sDllName & '" /codebase /tlb', @ScriptDir, @SW_HIDE)
64-
If $iExitCode = 0 Then
65-
$sLog &= "[+] x86 Registration: SUCCESS" & @CRLF
66-
$bSuccess = True
59+
If Not $bAbort Then
60+
; === Registration 'NetWebView2Lib.dll' COM ===
61+
Local $iExitCode
62+
63+
; Registration for x86 (32-bit)
64+
If FileExists($sNet4_x86) Then
65+
$iExitCode = RunWait('"' & $sNet4_x86 & '" "' & @ScriptDir & '\' & $sDllName & '" /codebase /tlb', @ScriptDir, @SW_HIDE)
66+
If $iExitCode = 0 Then
67+
$sLog &= "[+] x86 Registration: SUCCESS" & @CRLF
68+
$bSuccess = True
69+
Else
70+
$sLog &= "[-] x86 Registration: FAILED (Code: " & $iExitCode & ")" & @CRLF
71+
EndIf
6772
Else
68-
$sLog &= "[-] x86 Registration: FAILED (Code: " & $iExitCode & ")" & @CRLF
73+
$sLog &= "[!] x86 RegAsm not found" & @CRLF
6974
EndIf
70-
Else
71-
$sLog &= "[!] x86 RegAsm not found" & @CRLF
72-
EndIf
7375

74-
; Registration for x64 (64-bit)
75-
If FileExists($sNet4_x64) Then
76-
$iExitCode = RunWait('"' & $sNet4_x64 & '" "' & @ScriptDir & '\' & $sDllName & '" /codebase /tlb', @ScriptDir, @SW_HIDE)
77-
If $iExitCode = 0 Then
78-
$sLog &= "[+] x64 Registration: SUCCESS" & @CRLF
79-
$bSuccess = True
76+
; Registration for x64 (64-bit)
77+
If FileExists($sNet4_x64) Then
78+
$iExitCode = RunWait('"' & $sNet4_x64 & '" "' & @ScriptDir & '\' & $sDllName & '" /codebase /tlb', @ScriptDir, @SW_HIDE)
79+
If $iExitCode = 0 Then
80+
$sLog &= "[+] x64 Registration: SUCCESS" & @CRLF
81+
$bSuccess = True
82+
Else
83+
$sLog &= "[-] x64 Registration: FAILED (Code: " & $iExitCode & ")" & @CRLF
84+
EndIf
8085
Else
81-
$sLog &= "[-] x64 Registration: FAILED (Code: " & $iExitCode & ")" & @CRLF
86+
$sLog &= "[!] x64 RegAsm not found" & @CRLF
8287
EndIf
83-
Else
84-
$sLog &= "[!] x64 RegAsm not found" & @CRLF
8588
EndIf
8689

8790
; === Final Message ===
8891
If $bSuccess Then
92+
ConsoleWrite("+ Registration Complete" & @CRLF)
93+
ConsoleWrite($sLog & @CRLF)
94+
8995
MsgBox($MB_ICONINFORMATION, "Registration Complete", $sLog)
9096
Else
97+
ConsoleWrite("! Registration Error" & @CRLF)
98+
ConsoleWrite($sLog & @CRLF)
99+
91100
MsgBox($MB_ICONERROR, "Registration Error", "Library registration failed." & @CRLF & @CRLF & $sLog)
92101
EndIf
93102

94103
EndFunc ;==>_Register
95104

96105
;---------------------------------------------------------------------------------------
97106
Func WebView2Exist()
107+
;~ HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}
98108
Local $aKeys[3] = [ _
99109
"HKLM\SOFTWARE\Microsoft\EdgeUpdate\Clients", _
100110
"HKLM\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients", _
@@ -107,7 +117,9 @@ Func WebView2Exist()
107117
$sSubKey = RegEnumKey($sRootKey, $iIndex)
108118
If @error Then ExitLoop ; No more keys
109119
$sName = RegRead($sRootKey & "\" & $sSubKey, "name")
110-
If $sName = "Microsoft Edge WebView2 Runtime" Then
120+
ConsoleWrite("- Checking:" & $sRootKey & "\" & $sSubKey & "\name = " & $sName & @CRLF)
121+
If StringInStr($sName, "Microsoft Edge WebView2") Then
122+
ConsoleWrite("+ Found:" & $sRootKey & "\" & $sSubKey & "\name = " & $sName & @CRLF)
111123
$sPv = RegRead($sRootKey & "\" & $sSubKey, "pv")
112124
If $sPv <> "" Then Return $sPv ; Found it
113125
EndIf

0 commit comments

Comments
 (0)