摘要
如果有这样的需求,需要软件开机自启动,该如何做呢?开机自启动的做法,就是修改注册表,将你的exe注册到注册表Run节点下。
setupfactory
在安装的时候需要以管理员身份运行,这样可以保证你的操作有足够的权限。
在程序安装完成时,添加下面的脚本
脚本如下
isExist = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"); -- An if ... else statement that compares two numbers if (isExist) then -- Do something here Registry.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "test",
SessionVar.Expand("%AppFolder%\test.exe"), REG_SZ); else -- Do something else here Registry.CreateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"); Registry.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "test",
SessionVar.Expand("%AppFolder%\test.exe"), REG_SZ);
end
查看注册表
注意 如果你的系统是x64的 则再下面的key下能找到,你添加的注册项
HKEY_LOCAL_MACHINESOFTWAREWOW6432NodeMicrosoftWindowsCurrentVersionRun