Registry Creating DWORD problems

Satal Keto

Well-known member
Joined
May 15, 2006
Messages
86
Programming Experience
5-10
Hello I am trying to make a program for the administrators at my school.
What I am trying to do is make a program which the administrators can run on each computer in the school and it will edit the registry so that the children in the school can't access CMD or run batch files (as they was using it to send messages, which they weren't supposed to be able to).
I have written the program (very simple but this is my first VB.Net program so it would be simple anyway). The problem I have is that this simple code doesn't seem to work. I was wondering if anyone would be able to figure out why it doesn't work.

VB.NET:
Imports Microsoft
Imports Microsoft.Win32
Imports Microsoft.Win32.Registry
Public Class Form1

    Private Sub cmd_disable_cmd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_disable_cmd.Click
        'Software\Policies\Microsoft\Windows\System
        Dim key As RegistryKey
        key = Registry.CurrentUser.OpenSubKey("Software\Policies\Microsoft\Windows\System", True)
        Dim newkey As New Object
        newkey = key.CreateSubKey("DisableCMD")
        newkey.SetValue("DisableCMD", "1")
        key.Close()
    End Sub
End Class
I have attached a printscreen of the error that i recieve hopefully it will help.

Thank you for any help in advance
 

Attachments

  • Untitled-2.png
    Untitled-2.png
    98.8 KB · Views: 43
Try this instead, you'll need to change the values to the sub key and the key you want to create...

VB.NET:
Dim oReg As RegistryKey
oReg = Registry.LocalMachine.OpenSubKey("Software", True)
oReg = oReg.CreateSubKey("MyKey")
oReg.SetValue("MyKeyName", "MyKeyValue")
oReg.Close()
 
placing a string in the setValue's value field makes it a string key. Putting an integer makes it a DWORD
 
Back
Top