-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhyrox-Default-Browser.vbs
144 lines (124 loc) · 6.98 KB
/
Phyrox-Default-Browser.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
'Registers Phyrox with Default Programs or Default Apps in Windows
'FirefoxPortable.vbs - created by Ramesh Srinivasan for Winhelponline.com
'Phyrox-Default-Browser.vbs - modified by Bunny-Head
'v1.0 17-July-2022 - Initial release. Tested on Mozilla Firefox 102.0.1.0.
'v1.1 23-July-2022 - Minor bug fixes.
'v1.2 27-July-2022 - Minor revision. Cleaned up the code.
'Phyrox-Default-Browser fork created 13-January-2023
'Suitable for all Windows versions, including Windows 10/11.
'Tutorial: https://www.winhelponline.com/blog/register-firefox-portable-with-default-apps/
Option Explicit
Dim sAction, sAppPath, sExecPath, sIconPath, objFile, sbaseKey, sbaseKey2, sAppDesc
Dim sClsKey, ArrKeys, regkey
Dim WshShell : Set WshShell = CreateObject("WScript.Shell")
Dim oFSO : Set oFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = oFSO.GetFile(WScript.ScriptFullName)
sAppPath = oFSO.GetParentFolderName(objFile)
sExecPath = sAppPath & "\phyrox-portable.exe"
sIconPath = sAppPath & "\phyrox-portable.exe"
sAppDesc = "Firefox delivers safe, easy web browsing. " & _
"A familiar user interface, enhanced security features including " & _
"protection from online identity theft, and integrated search let " & _
"you get the most out of the web."
'Quit if phyrox-portable.exe is missing in the current folder!
If Not oFSO.FileExists (sExecPath) Then
MsgBox "Please run this script from Phyrox folder. The script will now quit.", _
vbOKOnly + vbInformation, "Register Phyrox with Default Apps"
WScript.Quit
End If
If InStr(sExecPath, " ") > 0 Then
sExecPath = """" & sExecPath & """"
sIconPath = """" & sIconPath & """"
End If
sbaseKey = "HKCU\Software\"
sbaseKey2 = sbaseKey & "Clients\StartmenuInternet\Phyrox\"
sClsKey = sbaseKey & "Classes\"
If WScript.Arguments.Count > 0 Then
If UCase(Trim(WScript.Arguments(0))) = "-REG" Then Call RegisterPhyrox
If UCase(Trim(WScript.Arguments(0))) = "-UNREG" Then Call UnRegisterPhyrox
Else
sAction = InputBox ("Type REGISTER to add Phyrox to Default Apps. " & _
"Type UNREGISTER To remove.", "Phyrox Registration", "REGISTER")
If UCase(Trim(sAction)) = "REGISTER" Then Call RegisterPhyrox
If UCase(Trim(sAction)) = "UNREGISTER" Then Call UnRegisterPhyrox
End If
Sub RegisterPhyrox
WshShell.RegWrite sbaseKey & "RegisteredApplications\Phyrox", _
"Software\Clients\StartMenuInternet\Phyrox\Capabilities", "REG_SZ"
'FirefoxHTML registration
WshShell.RegWrite sClsKey & "FirefoxHTML2\", "Firefox HTML Document", "REG_SZ"
WshShell.RegWrite sClsKey & "FirefoxHTML2\EditFlags", 2, "REG_DWORD"
WshShell.RegWrite sClsKey & "FirefoxHTML2\FriendlyTypeName", "Firefox HTML Document", "REG_SZ"
WshShell.RegWrite sClsKey & "FirefoxHTML2\DefaultIcon\", sIconPath & ",1", "REG_SZ"
WshShell.RegWrite sClsKey & "FirefoxHTML2\shell\", "open", "REG_SZ"
WshShell.RegWrite sClsKey & "FirefoxHTML2\shell\open\command\", sExecPath & _
" -url " & """" & "%1" & """", "REG_SZ"
WshShell.RegWrite sClsKey & "FirefoxHTML2\shell\open\ddeexec\", "", "REG_SZ"
'FirefoxPDF registration
WshShell.RegWrite sClsKey & "FirefoxPDF2\", "Firefox PDF Document", "REG_SZ"
WshShell.RegWrite sClsKey & "FirefoxPDF2\EditFlags", 2, "REG_DWORD"
WshShell.RegWrite sClsKey & "FirefoxPDF2\FriendlyTypeName", "Firefox PDF Document", "REG_SZ"
WshShell.RegWrite sClsKey & "FirefoxPDF2\DefaultIcon\", sIconPath & ",5", "REG_SZ"
WshShell.RegWrite sClsKey & "FirefoxPDF2\shell\open\", "open", "REG_SZ"
WshShell.RegWrite sClsKey & "FirefoxPDF2\shell\open\command\", sExecPath & _
" -url " & """" & "%1" & """", "REG_SZ"
'FirefoxURL registration
WshShell.RegWrite sClsKey & "FirefoxURL2\", "Firefox URL", "REG_SZ"
WshShell.RegWrite sClsKey & "FirefoxURL2\EditFlags", 2, "REG_DWORD"
WshShell.RegWrite sClsKey & "FirefoxURL2\FriendlyTypeName", "Firefox URL", "REG_SZ"
WshShell.RegWrite sClsKey & "FirefoxURL2\URL Protocol", "", "REG_SZ"
WshShell.RegWrite sClsKey & "FirefoxURL2\DefaultIcon\", sIconPath & ",1", "REG_SZ"
WshShell.RegWrite sClsKey & "FirefoxURL2\shell\open\", "open", "REG_SZ"
WshShell.RegWrite sClsKey & "FirefoxURL2\shell\open\command\", sExecPath & _
" -url " & """" & "%1" & """", "REG_SZ"
WshShell.RegWrite sClsKey & "FirefoxURL2\shell\open\ddeexec\", "", "REG_SZ"
'Default Apps Registration/Capabilities
WshShell.RegWrite sbaseKey2, "Phyrox", "REG_SZ"
WshShell.RegWrite sbaseKey2 & "Capabilities\ApplicationDescription", sAppDesc, "REG_SZ"
WshShell.RegWrite sbaseKey2 & "Capabilities\ApplicationIcon", sIconPath & ",0", "REG_SZ"
WshShell.RegWrite sbaseKey2 & "Capabilities\ApplicationName", "Phyrox", "REG_SZ"
WshShell.RegWrite sbaseKey2 & "Capabilities\FileAssociations\.pdf", "FirefoxPDF2", "REG_SZ"
WshShell.RegWrite sbaseKey2 & "Capabilities\StartMenu", "Phyrox", "REG_SZ"
WshShell.RegWrite sbaseKey2 & "DefaultIcon\", sIconPath & ",0", "REG_SZ"
WshShell.RegWrite sbaseKey2 & "shell\open\command\", sExecPath, "REG_SZ"
WshShell.RegWrite sbaseKey2 & "shell\properties\", "Firefox &Options", "REG_SZ"
WshShell.RegWrite sbaseKey2 & "shell\properties\command\", sExecPath & " -preferences", "REG_SZ"
WshShell.RegWrite sbaseKey2 & "shell\safemode\", "Firefox &Safe Mode", "REG_SZ"
WshShell.RegWrite sbaseKey2 & "shell\safemode\command\", sExecPath & " -safe-mode", "REG_SZ"
ArrKeys = Array ( _
"FileAssociations\.avif", _
"FileAssociations\.htm", _
"FileAssociations\.html", _
"FileAssociations\.shtml", _
"FileAssociations\.svg", _
"FileAssociations\.webp", _
"FileAssociations\.xht", _
"FileAssociations\.xhtml", _
"URLAssociations\http", _
"URLAssociations\https", _
"URLAssociations\mailto" _
)
For Each regkey In ArrKeys
WshShell.RegWrite sbaseKey2 & "Capabilities\" & regkey, "FirefoxHTML2", "REG_SZ"
Next
'Override the default app name by which the program appears in Default Apps (*Optional*)
'(i.e., -- "Mozilla Firefox, Portable Edition" Vs. "Phyrox")
'The official Mozilla Firefox setup doesn't add this registry key.
WshShell.RegWrite sClsKey & "FirefoxHTML2\Application\ApplicationIcon", sIconPath & ",0", "REG_SZ"
WshShell.RegWrite sClsKey & "FirefoxHTML2\Application\ApplicationName", "Phyrox", "REG_SZ"
'Launch Default Programs or Default Apps after registering Phyrox
WshShell.Run "control /name Microsoft.DefaultPrograms /page pageDefaultProgram"
End Sub
Sub UnRegisterPhyrox
sbaseKey = "HKCU\Software\"
sbaseKey2 = "HKCU\Software\Clients\StartmenuInternet\Phyrox"
On Error Resume Next
WshShell.RegDelete sbaseKey & "RegisteredApplications\Phyrox"
On Error GoTo 0
WshShell.Run "reg.exe delete " & sClsKey & "FirefoxHTML2" & " /f", 0
WshShell.Run "reg.exe delete " & sClsKey & "FirefoxPDF2" & " /f", 0
WshShell.Run "reg.exe delete " & sClsKey & "FirefoxURL2" & " /f", 0
WshShell.Run "reg.exe delete " & chr(34) & sbaseKey2 & chr(34) & " /f", 0
'Launch Default Apps after unregistering Phyrox
WshShell.Run "control /name Microsoft.DefaultPrograms /page pageDefaultProgram"
End Sub