Advertisement
Thrall72

mullvadportable.vbs

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