Skip to content

Commit 2fdb16d

Browse files
authored
Update Register_web2.au3 Au3Check support
1 parent 7b31df9 commit 2fdb16d

1 file changed

Lines changed: 108 additions & 97 deletions

File tree

bin/Register_web2.au3

Lines changed: 108 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,113 @@
11
#RequireAdmin
2+
#AutoIt3Wrapper_Run_AU3Check=Y
3+
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y
4+
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
5+
#Tidy_Parameters=/reel
6+
27
#include <MsgBoxConstants.au3>
38

4-
; === Configuration ===
5-
Local $sDllName = "NetWebView2Lib.dll"
6-
Local $sNet4_x86 = "C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe"
7-
Local $sNet4_x64 = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe"
8-
9-
Local $bSuccess = False
10-
Local $sLog = "Registration Report:" & @CRLF & "--------------------" & @CRLF
11-
12-
; === Check for WebView2 Runtime ===
13-
Local $sWV2Version = WebView2Exist()
14-
15-
If $sWV2Version <> "" Then
16-
$sLog &= "[+] WebView2 Runtime: Found (" & $sWV2Version & ")" & @CRLF
17-
Else
18-
Local $sUrl = "https://go.microsoft.com/fwlink/p/?LinkId=2124703"
19-
$sLog &= "[-] WebView2 Runtime: NOT FOUND" & @CRLF
20-
21-
; Ask the user to install
22-
Local $iAnswer = MsgBox($MB_YESNO + $MB_ICONEXCLAMATION, "Runtime Missing", _
23-
"The Microsoft Edge WebView2 Runtime is required to run this application." & @CRLF & @CRLF & _
24-
"Would you like to open the download page now?" & @CRLF & @CRLF & _
25-
"Note: Please return and click YES after the installation is complete.")
26-
27-
If $iAnswer = $IDYES Then
28-
ShellExecute($sUrl)
29-
; Wait for user confirmation that installation is done
30-
MsgBox($MB_ICONINFORMATION, "Waiting", "Click OK once the WebView2 installation is finished to proceed with DLL registration.")
31-
Else
32-
$sLog &= "[!] User skipped WebView2 installation. Aborting." & @CRLF
33-
MsgBox($MB_ICONSTOP, "Aborted", "Registration cannot continue without WebView2 Runtime.")
34-
Exit ; Stop the script
35-
EndIf
36-
EndIf
37-
38-
; === Registration 'NetWebView2Lib.dll' COM ===
39-
40-
; Registration for x86 (32-bit)
41-
If FileExists($sNet4_x86) Then
42-
Local $iExitCode = RunWait('"' & $sNet4_x86 & '" "' & @ScriptDir & '\' & $sDllName & '" /codebase /tlb', @ScriptDir, @SW_HIDE)
43-
If $iExitCode = 0 Then
44-
$sLog &= "[+] x86 Registration: SUCCESS" & @CRLF
45-
$bSuccess = True
46-
Else
47-
$sLog &= "[-] x86 Registration: FAILED (Code: " & $iExitCode & ")" & @CRLF
48-
EndIf
49-
Else
50-
$sLog &= "[!] x86 RegAsm not found" & @CRLF
51-
EndIf
52-
53-
; Registration for x64 (64-bit)
54-
If FileExists($sNet4_x64) Then
55-
Local $iExitCode = RunWait('"' & $sNet4_x64 & '" "' & @ScriptDir & '\' & $sDllName & '" /codebase /tlb', @ScriptDir, @SW_HIDE)
56-
If $iExitCode = 0 Then
57-
$sLog &= "[+] x64 Registration: SUCCESS" & @CRLF
58-
$bSuccess = True
59-
Else
60-
$sLog &= "[-] x64 Registration: FAILED (Code: " & $iExitCode & ")" & @CRLF
61-
EndIf
62-
Else
63-
$sLog &= "[!] x64 RegAsm not found" & @CRLF
64-
EndIf
65-
66-
; === Final Message ===
67-
If $bSuccess Then
68-
MsgBox($MB_ICONINFORMATION, "Registration Complete", $sLog)
69-
Else
70-
MsgBox($MB_ICONERROR, "Registration Error", "Library registration failed." & @CRLF & @CRLF & $sLog)
71-
EndIf
9+
_Register()
10+
11+
Func _Register()
12+
; === Configuration ===
13+
Local $sDllName = "NetWebView2Lib.dll"
14+
Local $sNet4_x86 = "C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe"
15+
Local $sNet4_x64 = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe"
16+
17+
Local $bSuccess = False
18+
Local $sLog = "Registration Report:" & @CRLF & "--------------------" & @CRLF
19+
20+
; === Check for WebView2 Runtime ===
21+
Local $sWV2Version = WebView2Exist()
22+
23+
If $sWV2Version <> "" Then
24+
$sLog &= "[+] WebView2 Runtime: Found (" & $sWV2Version & ")" & @CRLF
25+
Else
26+
Local $sUrl = "https://go.microsoft.com/fwlink/p/?LinkId=2124703"
27+
$sLog &= "[-] WebView2 Runtime: NOT FOUND" & @CRLF
28+
29+
; Ask the user to install
30+
Local $iAnswer = MsgBox($MB_YESNO + $MB_ICONEXCLAMATION, "Runtime Missing", _
31+
"The Microsoft Edge WebView2 Runtime is required to run this application." & @CRLF & @CRLF & _
32+
"Would you like to open the download page now?" & @CRLF & @CRLF & _
33+
"Note: Please return and click YES after the installation is complete.")
34+
35+
If $iAnswer = $IDYES Then
36+
ShellExecute($sUrl)
37+
; Wait for user confirmation that installation is done
38+
MsgBox($MB_ICONINFORMATION, "Waiting", "Click OK once the WebView2 installation is finished to proceed with DLL registration.")
39+
Else
40+
$sLog &= "[!] User skipped WebView2 installation. Aborting." & @CRLF
41+
MsgBox($MB_ICONSTOP, "Aborted", "Registration cannot continue without WebView2 Runtime.")
42+
Exit ; Stop the script
43+
EndIf
44+
EndIf
45+
46+
; === Registration 'NetWebView2Lib.dll' COM ===
47+
Local $iExitCode
48+
49+
; Registration for x86 (32-bit)
50+
If FileExists($sNet4_x86) Then
51+
$iExitCode = RunWait('"' & $sNet4_x86 & '" "' & @ScriptDir & '\' & $sDllName & '" /codebase /tlb', @ScriptDir, @SW_HIDE)
52+
If $iExitCode = 0 Then
53+
$sLog &= "[+] x86 Registration: SUCCESS" & @CRLF
54+
$bSuccess = True
55+
Else
56+
$sLog &= "[-] x86 Registration: FAILED (Code: " & $iExitCode & ")" & @CRLF
57+
EndIf
58+
Else
59+
$sLog &= "[!] x86 RegAsm not found" & @CRLF
60+
EndIf
61+
62+
; Registration for x64 (64-bit)
63+
If FileExists($sNet4_x64) Then
64+
$iExitCode = RunWait('"' & $sNet4_x64 & '" "' & @ScriptDir & '\' & $sDllName & '" /codebase /tlb', @ScriptDir, @SW_HIDE)
65+
If $iExitCode = 0 Then
66+
$sLog &= "[+] x64 Registration: SUCCESS" & @CRLF
67+
$bSuccess = True
68+
Else
69+
$sLog &= "[-] x64 Registration: FAILED (Code: " & $iExitCode & ")" & @CRLF
70+
EndIf
71+
Else
72+
$sLog &= "[!] x64 RegAsm not found" & @CRLF
73+
EndIf
74+
75+
; === Final Message ===
76+
If $bSuccess Then
77+
MsgBox($MB_ICONINFORMATION, "Registration Complete", $sLog)
78+
Else
79+
MsgBox($MB_ICONERROR, "Registration Error", "Library registration failed." & @CRLF & @CRLF & $sLog)
80+
EndIf
81+
82+
EndFunc ;==>_Register
83+
7284
;---------------------------------------------------------------------------------------
7385
Func WebView2Exist()
74-
Local $aKeys[3] = [ _
75-
"HKLM\SOFTWARE\Microsoft\EdgeUpdate\Clients", _
76-
"HKLM\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients", _
77-
"HKEY_CURRENT_USER\Software\Microsoft\EdgeUpdate\Clients" _
78-
]
79-
Local $sSubKey, $sName, $sPv, $iIndex
80-
81-
For $sRootKey In $aKeys
82-
For $iIndex = 1 To 500
83-
$sSubKey = RegEnumKey($sRootKey, $iIndex)
84-
If @error Then ExitLoop ; No more keys
85-
$sName = RegRead($sRootKey & "\" & $sSubKey, "name")
86-
If $sName = "Microsoft Edge WebView2 Runtime" Then
87-
$sPv = RegRead($sRootKey & "\" & $sSubKey, "pv")
88-
If $sPv <> "" Then Return $sPv ; Found it
89-
EndIf
90-
Next
91-
Next
92-
93-
Local $sSysPathX86 = @WindowsDir & "\System32\Microsoft-Edge-WebView\EBWebView\x86\EmbeddedBrowserWebView.dll"
94-
Local $sSysPathX64 = @WindowsDir & "\System32\Microsoft-Edge-WebView\EBWebView\x64\EmbeddedBrowserWebView.dll"
95-
96-
If FileExists($sSysPathX86) Or FileExists($sSysPathX64) Then
97-
Return "Detected via System Files"
98-
EndIf
99-
100-
Return "" ; Not found
101-
EndFunc
102-
;---------------------------------------------------------------------------------------
86+
Local $aKeys[3] = [ _
87+
"HKLM\SOFTWARE\Microsoft\EdgeUpdate\Clients", _
88+
"HKLM\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients", _
89+
"HKEY_CURRENT_USER\Software\Microsoft\EdgeUpdate\Clients" _
90+
]
91+
Local $sSubKey, $sName, $sPv, $iIndex
92+
93+
For $sRootKey In $aKeys
94+
For $iIndex = 1 To 500
95+
$sSubKey = RegEnumKey($sRootKey, $iIndex)
96+
If @error Then ExitLoop ; No more keys
97+
$sName = RegRead($sRootKey & "\" & $sSubKey, "name")
98+
If $sName = "Microsoft Edge WebView2 Runtime" Then
99+
$sPv = RegRead($sRootKey & "\" & $sSubKey, "pv")
100+
If $sPv <> "" Then Return $sPv ; Found it
101+
EndIf
102+
Next
103+
Next
104+
105+
Local $sSysPathX86 = @WindowsDir & "\System32\Microsoft-Edge-WebView\EBWebView\x86\EmbeddedBrowserWebView.dll"
106+
Local $sSysPathX64 = @WindowsDir & "\System32\Microsoft-Edge-WebView\EBWebView\x64\EmbeddedBrowserWebView.dll"
107+
108+
If FileExists($sSysPathX86) Or FileExists($sSysPathX64) Then
109+
Return "Detected via System Files"
110+
EndIf
111+
112+
Return "" ; Not found
113+
EndFunc ;==>WebView2Exist

0 commit comments

Comments
 (0)