[Winform]setupfactory打包时添加开机自启动的脚本
2017-08-23 12:53
232 查看
摘要
如果有这样的需求,需要软件开机自启动,该如何做呢?开机自启动的做法,就是修改注册表,将你的exe注册到注册表Run节点下。setupfactory
在安装的时候需要以管理员身份运行,这样可以保证你的操作有足够的权限。在程序安装完成时,添加下面的脚本
![](https://images2017.cnblogs.com/blog/511616/201708/511616-20170823124647839-1972396001.jpg)
脚本如下
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
查看注册表
![](https://images2017.cnblogs.com/blog/511616/201708/511616-20170823125049808-288684665.jpg)
注意 如果你的系统是x64的 则再下面的key下能找到,你添加的注册项
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run
相关文章推荐
- C# Winform打包部署时添加注册表信息实现开机启动
- CentOS6.5 添加开机自启动脚本
- 如何在ubuntu16.04上添加开机自启动的python脚本
- linux添加开机自启动脚本示例详解
- suse linux添加开机自启动脚本
- linux添加开机自启动脚本示例详解
- linux添加开机自启动脚本示例详解
- linux添加开机自启动脚本示例详解
- linux 添加开机自启动脚本
- Linux下添加自定义脚本到开机自启动的方法
- linux下添加自定义脚本到开机自启动的方法
- linux添加开机自启动脚本示例详解
- linux添加开机自启动脚本示例详解
- Linux下添加自定义脚本到开机自启动,标准rpm,举例:设置Apache自启动
- linux添加开机自启动脚本示例详解
- linux添加开机自启动脚本示例详解
- linux 添加开机自启动脚本
- 解压RK3288的boot.img修改init.rc 添加开机自启动脚本
- Linux下(以RedHat为范本)添加开机自启动脚本有两种方法