1

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

Num Educ
  • 55
  • 1
  • 1
  • 6
  • 1
    Welcome to Stack Overflow! Please take the [tour](http://stackoverflow.com/tour) and read [How to Ask](http://stackoverflow.com/help/how-to-ask) to learn what we expect from questions here. Please be aware that we do not provide from-scratch coding service here. Please show us what you've tried already, how it failed and we might be able to help. – Jørgen R Feb 26 '16 at 08:22
  • i testing this http://stackoverflow.com/questions/8884347/using-javascript-in-hta-file-to-read-write-from-windows-registry but not right – Num Educ Feb 26 '16 at 08:29
  • `WshShell.RegWrite "HKCU\Software\Gmail\Gmil", txtUserID.value, "REG_SZ"` –  Feb 26 '16 at 10:01
  • @NumEduc Did you mean you must run this HTA as Administrator ? – Hackoo Feb 26 '16 at 10:26
  • Hackoo i do not know – Num Educ Feb 26 '16 at 10:58
  • Then you need to give context. Your code will write a value called `Gmil` (maybe misspelt) under the `gmail` key with the value of `Value` –  Feb 26 '16 at 11:12

2 Answers2

0
Set WshShell = CreateObject("WScript.Shell")
WshShell.RegWrite "HKCU\Software\StackOverflow\VBS\Searchterm", tb1.value

tb1.value is a html text box.

Smandoli
  • 6,919
  • 3
  • 49
  • 83
  • so i have tested this http://www.tek-tips.com/viewthread.cfm?qid=1637005 with your code but not right – Num Educ Feb 26 '16 at 08:51
0

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>
Hackoo
  • 18,337
  • 3
  • 40
  • 70