Search code examples
htmlvbscriptkeyregistryhta

how to add registry value by hta or html file


i need add a registry value by html file my Registry value will be added in the Run and

HKEY_CURRENT_USER\SOFTWARE\

please how to creat this file by language vbscript in html file and I tested this

<html>
<head>
<title>Active Desktop Recovery</title>
<HTA:APPLICATION
  APPLICATIONNAME="Active Desktop Recovery"
  ID="MyHTMLapplication"
  VERSION="1.0"/>
</head>

<script language="VBScript">
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.RegWrite "HKCU\Software\Gmail\Gmil", "Value", "REG_SZ"
</script>

<body bgcolor="white">

<!--Add your controls here-->09:49 
<td><input name="txtComputerName" title="Enter a the computer you wish to query" TYPE="TEXT" SIZE="15"></td>
<td><input name="txtUserID" title="Enter available User ID" TYPE="TEXT" SIZE="50"></td>
<INPUT NAME="btnClearCSC" title="Clear CSC" TYPE="BUTTON" VALUE="Clear CSC">
<INPUT NAME="btnFindUser" title="Clear CSC" TYPE="BUTTON" VALUE="Find User">
<!--{{InsertControlsHere}}-Do not remove this line-->
</body>
</html>

thanks


Solution

  • Try this :

    <html>
    <head>
    <title>Active Desktop Recovery</title>
    <HTA:APPLICATION
      APPLICATIONNAME="Active Desktop Recovery"
      ID="MyHTMLapplication"
      VERSION="1.0"/>
    </head>
    <script language="VBScript">
    Option Explicit
    Dim WshShell,Title
    Title = "Active Desktop Recovery" 
    Set WshShell = CreateObject("WScript.Shell")
    '*************************************************************************
    Sub Write2Registry()
        WshShell.RegWrite "HKCU\Software\Gmail\Gmil",txtUserID.Value, "REG_SZ"
    end sub
    '*************************************************************************
    Sub ReadFromRegistry()
    On Error Resume Next
    Dim MyKey
        MyKey = WshShell.RegRead("HKCU\Software\Gmail\Gmil")
        If Err <> 0 Then
            MsgBox Err.Number & vbcr & Err.Description,vbCritical,Title
        Else
            MsgBox MyKey,vbInformation,Title
        End If  
    End Sub
    '*************************************************************************
    Sub DeleteKeyFromRegistry()
    On Error Resume Next
    Dim MyKey
        MyKey = WshShell.RegDelete("HKCU\Software\Gmail\")
        If Err <> 0 Then
            MsgBox Err.Number & vbcr & Err.Description,vbCritical,Title
        Else
            'MsgBox MyKey,vbInformation,Title
        End If  
    End Sub
    </script>
    <body bgcolor="white">
    <td><input name="txtUserID" title="Enter available User ID" TYPE="TEXT" SIZE="50"></td>
    <br><br>
    <INPUT NAME="btnWriteKey" title="WriteKey" TYPE="BUTTON" VALUE="WriteKey" OnClick="Write2Registry()">
    <INPUT NAME="btnReadKey" title="ReadKey" TYPE="BUTTON" VALUE="ReadKey" OnClick="ReadFromRegistry()">
    <INPUT NAME="btnDeleteKey" title="btnDeleteKey" TYPE="BUTTON" VALUE="DeleteKey" OnClick="DeleteKeyFromRegistry()">
    </body>
    </html>