Created
February 25, 2017 19:01
-
-
Save JohnLaTwC/2e73983056dcfae3ad5c4499e5c8aa2c to your computer and use it in GitHub Desktop.
Reassociate file types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub AutoOpen() | |
Call FileTypeSet | |
End Sub | |
Sub AutoClose() | |
Call FileTypeReset | |
End Sub | |
Sub FileTypeReset() | |
Dim g_szAsocArray: g_szAsocArray = Array("JSEFile", "JSFile", "VBEFile", "VBSFile", "WSHFile", "WSFFile") | |
Dim oWSH | |
Dim szExt | |
Set oWSH = CreateObject("WScript.Shell") | |
For Each szExt In g_szAsocArray | |
Dim szKey | |
szKey = "HKCU\Software\Classes\" & szExt & "\shell\open\command\" | |
On Error Resume Next | |
Debug.Print "Deleting " & szKey | |
Err.Clear | |
oWSH.RegDelete szKey | |
If Err.Number <> 0 Then Debug.Print "Error was " & Hex(Err.Number) | |
Next | |
End Sub | |
Sub FileTypeSet() | |
Dim g_szAsocArray: g_szAsocArray = Array("JSEFile", "JSFile", "VBEFile", "VBSFile", "WSHFile", "WSFFile") | |
Dim oWSH | |
Dim szExt | |
Set oWSH = CreateObject("WScript.Shell") | |
For Each szExt In g_szAsocArray | |
Dim szKey | |
szKey = "HKCU\Software\Classes\" & szExt & "\shell\open\command\" | |
On Error Resume Next | |
Debug.Print "Adding " & szKey | |
oWSH.RegWrite szKey, "C:\windows\system32\notepad.exe %1", "REG_SZ" | |
If Err.Number <> 0 Then Debug.Print "Error was " & Hex(Err.Number) | |
Next | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment