简体   繁体   English

从安装项目重新启动系统

[英]Reboot system from Setup project

I am creating a setup project using Visual Studio. 我正在使用Visual Studio创建一个安装项目。 I want to reboot the system after the installation completed successfully. 我想在安装成功完成后重启系统。

I want it one time effort. 我想要一次性的努力。 I do not want to modify the setup each time using any external tool/ utility before delivering it to client. 我不希望每次使用任何外部工具/实用程序修改设置,然后再将其提供给客户端。

Can I tweak the setup project itself? 我可以调整安装项目本身吗?

How Can I do that? 我怎样才能做到这一点?

You can use ORCA to do this. 您可以使用ORCA执行此操作。

See this Microsoft HOW TO article for details: 有关详细信息,请参阅此Microsoft HOW TO文章:

http://support.microsoft.com/kb/827020 http://support.microsoft.com/kb/827020

Try this out: 试试这个:

Create an empty merge module project, in a separate solution and build it. 在单独的解决方案中创建一个空的合并模块项目并构建它。 This will create a msm file in the project's Debug or Release folder. 这将在项目的Debug或Release文件夹中创建一个msm文件。

Edit the resulting msm in Orca - setting the REBOOT=Force property as shown here . 编辑Orca中产生的MSM -设置重启=强制属性如图所示这里 You'll only have to do this once. 你只需要这样做一次。

In your main solution, add the merge module to your setup project and build it. 在主解决方案中,将合并模块添加到安装项目并构建它。 Since the merge module was built separately, it will keep the reboot property and merge it into your MSI. 由于合并模块是单独构建的,因此它将保留reboot属性并将其合并到您的MSI中。

Please dont swhoot me down, but Im not going to answer your specific question, however this is a way to reboot PC after an msi install. 请不要让我失望,但我不会回答您的具体问题,但这是一种在msi安装后重启PC的方法。

Use WiX instead, it is so much more flexible the the VS built in setup, and there is a plugin for VS. 使用WiX ,VS内置设置更加灵活,VS有一个插件。

If you do use WiX this is the code that initiates a reboot. 如果您使用WiX,则这是启动重新启动的代码。

<InstallExecuteSequence>
  <ScheduleReboot After='InstallFinalize' />
</InstallExecuteSequence>

Alternatively you could create a transform for your VS setup project that only contains the additional entries to initiate the reboot, then anytime you build your project all you need do is apply the transform, you could ship this to customers in a batch file or similar. 或者,您可以为VS安装项目创建一个转换,该转换仅包含用于启动重新启动的其他条目,然后您构建项目的任何时候都需要执行转换,您可以将其发送给批处理文件或类似的客户。

ps bear in mind that issuing a shell command as a custom action is not the best way to do it. ps请记住,发出shell命令作为自定义操作并不是最好的方法。 This will cause the machine to reboot and not return the proper exit code 3010 so if someone is trying to trap the exit code or do a /norestart on the command line the shell command will ignore this. 这将导致计算机重新启动并且不返回正确的退出代码3010,因此如果有人试图捕获退出代码或在命令行上执行/ norestart,则shell命令将忽略此操作。

EDIT Once you have created a msi file open it up with orca and then add the necessary changes to the tables to schedulereboot. 编辑一旦你创建了一个msi文件,用orca打开它,然后在表格中添加必要的更改到schedulereboot。 Save the changes as a transform then as long as the msi file doesnt change dramatically you can simply apply the transform to the msi everytime you run it. 将更改保存为转换,然后只要msi文件没有显着变化,您就可以在每次运行时将转换应用到msi。

Personaly I wouldnt want to do this as it is an extra step and you ought to be able to do it in the source. Personaly我不想这样做,因为它是一个额外的步骤,你应该能够在源头做到这一点。

To add the reboot sequence in orca goto the InstallExecuteSequence table and find the InstallFinalize entry. 要在orca中添加重新启动序列,请转到InstallExecuteSequence表并找到InstallFinalize条目。 Add a new entry called ScheduleReboot and enter a number in the sequence column that is 1 greater than the sequence from the InstallFinalize stage. 添加一个名为ScheduleReboot的新条目,并在序列列中输入一个比InstallFinalize阶段的序列大1的数字。

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

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