我一直在关注在 MSI 安装结束时添加复选框以打开已安装产品的解决方案:
在 msi 安装后运行 exe?
到目前为止,一切都很好。但是,我想添加另一个复选框,用于打开一个包含发行说明的简单文本文件。该文件已与主输出一起包含在安装项目中。我可以添加一个新的复选框。唯一的问题是如何打开该文本文件:似乎没有自定义操作适合此需求,正如我在这里看到的那样:http: //msdn.microsoft.com/en-us/library/windows/desktop/aa372048%28v=vs .85%29.aspx
这是我当前的 JS 代码:
var sql
var view
var checkboxTextForReleaseNotes = "See release notes";
var fileReleaseNotes = "ReleaseNotes.txt";
try
{
var fileIdForReleaseNotes = FindFileIdentifier(database, fileReleaseNotes);
if (!fileIdForReleaseNotes)
throw "Unable to find '" + fileReleaseNotes + "' in File table";
[ ... some actions to include another control as seen in link above ... ]
// Insert the new CheckboxReleaseNotes control
sql = "INSERT INTO `Control` (`Dialog_`, `Control`, `Type`, `X`, `Y`, `Width`, `Height`, `Attributes`, `Property`, `Text`, `Control_Next`, `Help`) VALUES ('FinishedForm', 'CheckboxReleaseNotes', 'CheckBox', '18', '140', '343', '12', '3', 'LAUNCH_RN', '{\\VSI_MS_Sans_Serif13.0_0_0}" + checkboxTextForReleaseNotes + "', 'CloseButton', '|')";
view = database.OpenView(sql);
view.Execute();
view.Close();
// Modify the Order of the EndDialog event of the FinishedForm to 1
sql = "SELECT `Dialog_`, `Control_`, `Event`, `Argument`, `Condition`, `Ordering` FROM `ControlEvent` WHERE `Dialog_`='FinishedForm' AND `Event`='EndDialog'";
view = database.OpenView(sql);
view.Execute();
record = view.Fetch();
record.IntegerData(6) = 1;
view.Modify(msiViewModifyReplace, record);
view.Close();
// Insert the Event to launch the release notes
sql = "INSERT INTO `ControlEvent` (`Dialog_`, `Control_`, `Event`, `Argument`, `Condition`, `Ordering`) VALUES ('FinishedForm', 'CloseButton', 'DoAction', 'OPEN_RN', 'LAUNCH_RN=1', '0')";
view = database.OpenView(sql);
view.Execute();
view.Close();
// Insert the custom action to open the release notes when finished
sql = "INSERT INTO `CustomAction` (`Action`, `Type`, `Source`, `Target`) VALUES ('OPEN_RN', '210', '" + fileIdForReleaseNotes + "', '')";
view = database.OpenView(sql);
view.Execute();
view.Close();
database.Commit();
}
catch (e)
{
WScript.StdErr.WriteLine(e);
WScript.Quit(1);
}
我知道自定义操作的类型“210”不是正确的......但是有吗?或者我真的必须通过启动 Jscript 或 VBScript 来完成我的工作吗?
编辑:代码结束。还尝试通过“vdproj”属性添加自定义操作,但由于文件不兼容而被拒绝。