[Winform]setupfactory打包時添加開機自啟動的腳本
阿新 • • 發佈:2017-08-23
自啟動 如何 var version col src idt span 開機自啟
摘要
如果有這樣的需求,需要軟件開機自啟動,該如何做呢?開機自啟動的做法,就是修改註冊表,將你的exe註冊到註冊表Run節點下。
setupfactory
在安裝的時候需要以管理員身份運行,這樣可以保證你的操作有足夠的權限。
在程序安裝完成時,添加下面的腳本
腳本如下
isExist = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"); -- An if ... else statement that compares two numbersif (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_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run
[Winform]setupfactory打包時添加開機自啟動的腳本