我想通过编写注册表
使应用程序在启动时运行Dim regKey As RegistryKey
regKey = Registry.LocalMachine.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
regKey.SetValue("exitit", "exitit.exe")
但是此代码在没有任何错误或例外的情况下无效。
注意:此代码适用于除 HKEY_LOCAL_MACHINE \ Software \ Microsoft \ Windows \ CurrentVersion \ Run
之外的其他位置答案 0 :(得分:1)
我过去也遇到过这个命令的麻烦,无法解决它,但我用regedit命令解决它:
include
这应该对你有用,如果你打算分配一个包含空格的值,你必须用Chr(34)键入它(作为"")。例如:
Process.Start("cmd", "/c reg ADD HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run /v exitit /t REG_SZ /d exitit.exe /f")
答案 1 :(得分:0)
Private keyRUN As RegistryKey
Private str_run As String
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
str_run = "Software\Microsoft\Windows\CurrentVersion\Run"
keyRUN = Registry.LocalMachine.OpenSubKey(str_run, True)
keyRUN.SetValue("exitit", "exitit.exe", RegistryValueKind.String)
End Sub