Dim starupPath = ProjectPath & "自动备份管理系统.exe"
MessageBox.Show(starupPath)
Dim loca = Microsoft.Win32.Registry.LocalMachine
Dim run = loca.CreateSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run")
'run.SetValue("自动备份管理系统", False) '取消开机运行
run.SetValue("自动备份管理系统", starupPath) '设置开机运行
loca.Close()
参考:http://www.foxtable.com/webhelp/topics/2051.htm
运行代码的程序要设置为“以管理员身份运行”
Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run","自动备份管理系统",starupPath)
我的路径是E:\开发\自动备份\自动备份系统\Publish\
自动备份管理系统.exe
ApplicationPath & "自动备份管理系统.exe" 生成的目录是E:\开发\自动备份\自动备份系统\Publish\project\自动备份管理系统.exe
这怎么解决?
【ApplicationPath & "自动备份管理系统.exe"】绝对不可能是Publish\project\里的路径
设置为空值
Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run","自动备份管理系统","")