[Winform]setupfactory打包时添加开机自启动的脚本

2021-09-18 00:14

阅读:701

标签:系统   exe   eth   完成   factor   numbers   alt   程序   color   摘要 如果有这样的需求,需要软件开机自启动,该如何做呢?开机自启动的做法,就是修改注册表,将你的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_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run[Winform]setupfactory打包时添加开机自启动的脚本标签:系统   exe   eth   完成   factor   numbers   alt   程序   color   原文地址:http://www.cnblogs.com/wolf-sun/p/7417654.html


评论


亲,登录后才可以留言!