Prawdziwe oblicze Informatyki. Tysiące linijek kodu i kompilatory które nigdy nie wybaczają.
Awatar użytkownika

WinSxS

Zasłużony użytkownik
Posty: 396
Rejestracja: 03 lut 2016, 20:36
    Windows Server 2003/XP x64 Chrome

Post15 mar 2024, 12:43

How to add registry key from HTML Application (HTA) - snippet example
Jak dodać klucz rejestru spod aplikacji HTML (HTA) - przykładowy wycinek
Angielski język w temacie dla pozycjonowania w wyszukiwarkach.

Example:
Add Open File Location (Find Target) to context menu

Example reg file:

Kod: Zaznacz cały

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\Open File Location]
@="&Open File Location"

[HKEY_CLASSES_ROOT\Directory\shell\Open File Location\command]
@="\"explorer.exe\" /select,\"%1\""

[HKEY_CLASSES_ROOT\*\shell]

[HKEY_CLASSES_ROOT\*\shell\Open File Location]
@="&Open File Location"

[HKEY_CLASSES_ROOT\*\shell\Open File Location\command]
@="\"explorer.exe\" /select,\"%1\""
Example HTA Code:

Kod: Zaznacz cały

<script language="VBScript">
Option Explicit
Dim WshShell,Title
Title = "Open File Location" 
Set WshShell = CreateObject("WScript.Shell")
'*************************************************************************
Sub Write2Registry()
    WshShell.RegWrite "HKCR\Directory\Shell\Open File Location","&Open File Location", "REG_SZ"
    WshShell.RegWrite "HKCR\*\Shell\Open File Location","&Open File Location", "REG_SZ"
    WshShell.RegWrite "HKCR\Directory\shell\Open File Location\command\",Chr(34)& "explorer.exe" &Chr(34)& " /select," & Chr(34) & "%1" & Chr(34), "REG_SZ"
    WshShell.RegWrite "HKCR\*\shell\Open File Location\command\",Chr(34)& "explorer.exe" &Chr(34)& " /select," & Chr(34) & "%1" & Chr(34), "REG_SZ"
end sub
'*************************************************************************
Sub DeleteKeyFromRegistry()
On Error Resume Next
Dim MyKey
    MyKey = WshShell.RegDelete("HKCR\Directory\Shell\Open File Location\command\")
    MyKey = WshShell.RegDelete("HKCR\Directory\Shell\Open File Location\")
    MyKey = WshShell.RegDelete("HKCR\*\Shell\Open File Location\command\")
    MyKey = WshShell.RegDelete("HKCR\*\Shell\Open File Location\")
    If Err <> 0 Then
        MsgBox Err.Number & vbcr & Err.Description,vbCritical,Title
    Else
        'MsgBox MyKey,vbInformation,Title
    End If  
End Sub
</script>
<br><br>
<INPUT NAME="btnWriteKey" title="WriteKey" TYPE="BUTTON" VALUE="Install" OnClick="Write2Registry()">
<INPUT NAME="btnDeleteKey" title="btnDeleteKey" TYPE="BUTTON" VALUE="Remove" OnClick="DeleteKeyFromRegistry()">
Explanation/Wyjaśnienie:

Chr(34)& "explorer.exe" &Chr(34)& " /select," & Chr(34) & "%1" & Chr(34)

Chr(34) = "
& = sums phrases on left and right
Chr(34)& "explorer.exe" &Chr(34) = "explorer.exe"
Chr(34)& "explorer.exe" &Chr(34)& " /select," & Chr(34) & "%1" & Chr(34) = "explorer.exe" /select,"%1"

That code may request for administrator privileges in Vista+.
Obrazek Notebook: (HP Pavilion 15-eh1000nw) Ryzen 5 5500U + 8 GB DDR4-3200 + Windows 11
Powerful XP machine: Core i5 2500K + 16 GB DDR3-1333 + ASUS P8H67 + GTX 550 Ti + dualboot Windows XP x86/x64
Server/NAS: (Acer E1-530G) Pentium 2117U + 12 GB DDR3-1600 + Windows Server 2008 R2
Spoiler
Network: 600 Mbps / ARRIS TG6441B + TP-Link WR740N as wireless extender/access point
Phone: Vivo v33s 8 GB/128 GB
Console: Xbox One 1gen 500 GB
TV: Xiaomi Mi LED TV 55"

Kto jest online

Użytkownicy przeglądający to forum: Obecnie na forum nie ma żadnego zarejestrowanego użytkownika i 3 gości