Setup Factory打包教程整合

一些简单的过程就不详细写了,就写一些可能会遇到的问题。
我使用的是Setup Factory 9.0.3.0 汉化版,资源地址:
https://download.csdn.net/download/woaishapi/7789171
这个是我参考的打包教程:
https://dominick-li.blog.csdn.net/article/details/83149751(不是Java应用打包也可以用的,这里面的1、2、4、6可以参考,3和5我在下面用了别的方法,7写错了我下面会写正确的)
http://t.zoukankan.com/lidabo-p-9809757.html(里面有打包过程、设置安装序列号、“到期”属性等)

1.卸载程序

自带的卸载程序uninstall.exe双击会报错,所以自己写一个卸载程序。
在Setup Factory软件左侧列表中点击【操作】-【关于安装之后】,在【On Post Install】里写入以下代码:

Shell.CreateShortcut(SessionVar.Expand("%AppFolder%"), SessionVar.Expand("卸载%ProductName%"), SessionVar.Expand("%AppFolder%\\uninstall.exe"), SessionVar.Expand("%AppFolder%\\uninstall.exe \"/U:%AppFolder%\\Uninstall\\uninstall.xml\""), SessionVar.Expand("%AppFolder%"), SessionVar.Expand("%AppFolder%\\uninstall.exe"), 0, SW_SHOWNORMAL, nil, "");

然后点击【卸载】-【操作】,在【On Post Uninstall】里写入以下代码:

resultF = Folder.DoesExist(SessionVar.Expand("%AppFolder%"));
if (resultF) then
Folder.DeleteTree(SessionVar.Expand("%AppFolder%"),nil);
end

安装发布包后,生成的文件夹中的uninstall.exe还是不起作用的,起作用的是我们上面写的卸载项目名.exe。

2.开机自启动

以下两个方法都自测可用:

1)写入注册表的方式
点击【操作】-【关于安装之后】,在【On Post Install】里写入以下代码:

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","Message", 
SessionVar.Expand("%AppFolder%\\%ProductName%.exe"),REG_SZ); 
else 
-- Do something else here 
Registry.CreateKey(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\windows\\CurrentVersion\\Run"); 
Registry.SetValue(HKEY_LOCAL_MACHINE,REG_SZ); 
end 

%ProductName%是要开机自启的应用程序名,如果不是项目名就自己改掉。
卸载的话需要删除注册表,点击【卸载】-【操作】,在【On Post Uninstall】里写入代码,结合上面本身的卸载程序,就变成了:

resultF = Folder.DoesExist(SessionVar.Expand("%AppFolder%"));
if (resultF) then
Registry.DeleteValue(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", "Message");
Folder.DeleteTree(SessionVar.Expand("%AppFolder%"),nil);
end

这个注册表可以在\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run找到。

2)快捷方式放入开机自启的文件夹中
WIN10自测可用,右击exe文件选择【文件属性】,在【快捷方式】-【位置】,勾选【自定义】,并填入C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp。
在这里插入图片描述

3.更换安装目录时补全应用名称

在安装时选择非默认安装目录时,项目名会丢失,所以需要自己进行一些修改。(也就是开始时说的有点问题的教程)
需要在Setup Factory安装目录下找到文件_SUF70_Global_Functions.lua,用记事本打开并找到g_EditFieldFolderBrowse,把这个函数改为如下图所示:
在这里插入图片描述
代码:

-- replace the contents of the edit field with the folder path that was selected
-- tbEditProps.Text = strTargetFolder;
strCCCn = SessionVar.Expand("\\%ProductName%");
tbEditProps.Text = strTargetFolder..strCCCn;
DlgEditField.SetProperties(nIDEditField, tbEditProps);

4.安装新版本并卸载前一版本

https://blog.csdn.net/hejingdong123/article/details/94440905(自动卸载)
https://blog.csdn.net/andr0id/article/details/106861372(需先手动确认卸载)

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值