简体   繁体   English

安装程序安装完成后重新启动的最简单方法是什么?

[英]What is the simplest way to reboot after a Setup Project installation completes?

I hate to ask this question as I am aware that there are plenty of questions about it already, some coming very close to what I am wanting to do: 我不想问这个问题,因为我知道有很多关于它的问题,有些问题非常接近我想要做的事情:

The first one seems to suggest that it is impossible without external software but the second question gives an answer that seems exactly what I want. 第一个似乎暗示没有外部软件就不可能,但第二个问题给出了一个看起来正是我想要的答案。 But I don't really understand what it's referring to when it's suggested to set REBOOT=Force . 但是当我建议设置REBOOT=Force时,我并不真正理解它所指的是什么。

I read through the linked articles about properties, I don't know if it's just the way MSDN is written but I feel none the wiser about how I'm supposed to use them in a setup project. 我阅读了有关属性的链接文章,我不知道它是否只是MSDN的编写方式,但我觉得我不应该如何在安装项目中使用它们。 I'm still fairly new to C# in general and Setup Projects specifically. 我对C#一般都很陌生,特别是Setup Projects。

Outside of properties it seems like the next easiest thing to do with the least external dependencies is to create a little C# application, which does nothing but shutdown the system. 在属性之外,似乎下一个最简单的事情是使用最少的外部依赖项来创建一个小的C#应用​​程序,除了关闭系统之外什么都不做。 Then add a Custom Action to the Commit section to call this application. 然后将“自定义操作”添加到“提交”部分以调用此应用程序。 This seems like an overkill to me and does that mean that the useless application has to be part of the installation and left on the users machine? 这似乎对我来说太过分了,这是否意味着无用的应用程序必须是安装的一部分并留在用户机器上?

I've found plenty of stuff about using WIX or Orca but I have my reasons for not using them (at the very least because I have to write Business Cases for any software used). 我发现了很多关于使用WIX或Orca的东西,但我有理由不使用它们(至少因为我必须为所使用的任何软件编写Business Cases)。 I am not even trying to create a very complicated installer, it is just a few new EXEs being copied over and then restarting to be sure that the new EXE is used at startup. 我甚至没有尝试创建一个非常复杂的安装程序,它只是一些新的EXE被复制然后重新启动以确保在启动时使用新的EXE。 Though I am now thinking that it may not be worth the hassle of restarting and just call the new exe as a custom action. 虽然我现在认为重新启动麻烦可能不值得,只需将新的exe调用为自定义操作。

REBOOT is a predefined Windows Installer property: http://msdn.microsoft.com/en-us/library/windows/desktop/aa371101(v=vs.85).aspx REBOOT是预定义的Windows Installer属性: http//msdn.microsoft.com/en-us/library/windows/desktop/aa371101( v = vs.85) .aspx

Installer properties are stored in Property table from the MSI database. 安装程序属性存储在MSI数据库的Property表中 So you can simply add a new row in Property table with this information: 因此,您只需在Property表中添加一个包含以下信息的新行:

  • Property - REBOOT 物业 - 重新启动
  • Value - Force 价值 - 力量

You can read more about installer properties here: http://msdn.microsoft.com/en-us/library/windows/desktop/aa372432(v=vs.85).aspx?ppud=4 您可以在此处阅读有关安装程序属性的更多信息: http//msdn.microsoft.com/en-us/library/windows/desktop/aa372432(v = vs.85).aspx?pp = 4

Please note that Visual Studio setup projects do not support setting property values. 请注意,Visual Studio安装项目不支持设置属性值。 So you can either edit the MSI with Orca to add the new row or switch to a different setup authoring tool. 因此,您可以使用Orca编辑MSI以添加新行或切换到其他设置创作工具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM