Che*_*eso 27 installation setup-project visual-studio-2008 visual-studio
我有一个Visual Studio安装项目.安装后,它会在应用程序文件夹中创建卸载批处理文件.如果用户想要卸载产品,他可以转到"添加/删除程序",或者只需双击uninstall.cmd即可.内容如下:
%windir%\system32\msiexec /x {CC3EB7BF-DD82-48B9-8EC5-1B0B62B6D285}
Run Code Online (Sandbox Code Playgroud)
GUID是Visual Studio中安装项目的ProductCode.

但是,为了使升级正常工作,我每次生成新的MSI时都必须增加版本号.而且,如果我增加版本号,那么我还必须为ProductCode生成一个新的Guid.这意味着静态uninstall.cmd文件需要更改.
如何在构建时动态生成包含ProductCode的批处理文件?
Ben*_*Ben 65
我在这里找到了解决方案
"使用Visual Studio 2005/2008,您不需要编写任何代码来为安装项目添加卸载选项(是的,我知道有些人可以编写代码来执行此操作)
1)在安装项目 - >文件系统窗口 - >右键单击"目标机器上的文件系统" - >添加特殊文件夹,选择系统文件夹;
2)进入此系统文件夹添加文件.从本地System32文件夹中浏览msiexec.exe并添加它.覆盖此文件的默认属性,如下所示:
条件:=未安装(确保你把'Not Installed'完全相同,相同的情况和所有内容),Permanent:= True,System:= True,Transitive:= True,Vital:= False.
3)在"用户程序菜单"下创建一个新快捷方式,将目标设置为您在步骤1中创建的系统文件夹,并将其指向msiexec.exe.将快捷方式重命名为"卸载应用程序".将Arguments属性设置为/ x {space} [ProductCode].
4)构建项目,忽略有关msiexec应被排除,不要排除它或安装项目不会构建的事实的警告.
"未安装"条件和Permananet:= True确保msiexec.exe仅作为安装的一部分放入系统文件夹中,如果它不存在,并且在卸载时不会删除它 - 因此它; s非常安全地忽略那个警告并且只是为了它.
(根据SlapHead的描述)"
MPe*_*ier 11
我做了这个工作:
将uninstall.bat文件添加到项目中.文件内容是:
msiexec.exe /x %1
Run Code Online (Sandbox Code Playgroud)
创建该批处理文件的快捷方式(例如在用户程序菜单中),在快捷方式的属性中指定Arguments : [ProductCode].
这是我编写的用于创建 uninstall.cmd 的脚本。它在安装过程中作为自定义操作运行。
var fso, ts;
var ForWriting= 2;
fso = new ActiveXObject("Scripting.FileSystemObject");
var parameters = Session.Property("CustomActionData").split("|");
var targetDir = parameters[0];
var productCode = parameters[1];
ts = fso.OpenTextFile(targetDir + "uninstall.cmd", ForWriting, true);
ts.WriteLine("@echo off");
ts.WriteLine("goto START");
ts.WriteLine("=======================================================");
ts.WriteBlankLines(1);
ts.WriteLine(" Uninstall.cmd");
ts.WriteBlankLines(1);
ts.WriteLine("=======================================================");
ts.WriteBlankLines(1);
ts.WriteLine(":START");
ts.WriteLine("@REM The uuid is the 'ProductCode' in the Visual Studio setup project");
ts.WriteLine("%windir%\\system32\\msiexec /x " + productCode);
ts.WriteBlankLines(1);
ts.Close();
Run Code Online (Sandbox Code Playgroud)
结果是一个 cmd 文件,其中始终包含当前的 ProductCode。
这样做的坏处是?创建 uninstall.cmd 的脚本保留在安装目录中。不是一个大问题,但我不喜欢安装目录中的垃圾。我还没有尝试使“createInstaller.js”自删除。这可能有用。
编辑:是的,使 createInstaller.js 自删除工作正常。
我要接受我自己的答案!
| 归档时间: |
|
| 查看次数: |
44414 次 |
| 最近记录: |