仅当打开多个会话时,如何在 wix 中安排重新启动 [英] How to ScheduleReboot in wix only if several sessions are opened

查看:16
本文介绍了仅当打开多个会话时,如何在 wix 中安排重新启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法,仅在有多个用户登录到目标计算机的情况下,才能在 WIX 安装程序中使用提示 ScheduleReboot 操作.到目前为止,我找不到条件或其他内置方式来做到这一点,我决定在编写自定义操作之前先在​​这里询问.

I am looking for a way to use prompt ScheduleReboot action in WIX installer only in the condition there is more than one user logged in to the target machine. So far I couldn't find a condition or other built in way to do that, I decided to ask here before writing a custom action.

谢谢.

对@Stein Asmul 问题的回答:
该应用程序是一个开发工具,可以部署在任何类型的机器上,任何类型的 Windows 操作系统都比 Windows xp 更新.我需要在打开多个会话的情况下重新启动,因为该应用程序涉及多个用户拥有的进程,这些进程在安装期间启动,然后在 Windows 启动时启动.当这些进程对一个用户关闭而对另一个用户打开时,可能会导致应用程序处于无效状态,或者至少是我们不打算支持的状态.由于我没有简单的方法为不是运行安装的登录用户启动这些进程,因此要求重新启动对我来说是一个可以接受的解决方案.

answers to @Stein Asmul qustions:
The app is a dev tool that could be deployed on any type of machine with any type of windows os newer than Windows xp. I need to restart on the case of more than one opened session since the app involves several user-owned processes that are being started during the installation and then on windows startup. When these processes are off for one user and on for another it could lead to an invalid state of the app, or at least to a state that we are not planning to support. Since I have no easy way to start these processes for a logged on user that is not the one who ran the installation, asking a restart is an acceptable solution for me.

我可以为 winform 编写代码,该代码使用 WMI 查询检查登录用户的数量并根据响应提供重新启动,即使使用其他人已经编写和测试的代码总是很好.我想我可以编写一个 Wix CustomAction 来保存一个属性,该属性指示是否有多个交互式登录,然后将其用作 ScheduleReboot 的条件,但与 Wix 中的许多事情一样,它会很复杂,很难调试和最终结果几乎相似.当然,我更愿意从某个地方获得一种经过测试的Wix"方式来做到这一点,因为一个简单的 winform 将我的选择限制在我可以用 Wix 做的事情上,但我没有找到任何东西,这不是我要去的东西立即进入.

I have no problem writing the code for a winform that checks the number of logged on users with a WMI query and based on the response offers to restart, even though it's always nice to use someone else's already written and tested code. I guess I could write a Wix CustomAction that saves a property indicating if the there is more than one interactive log-on and then use it as a condition for a ScheduleReboot, but like many things in Wix, it would be complicated, very hard to debug and the end result would be almost similar. I would, of course, prefer to get from somewhere a tested "Wix" way to do that since a simple winform limit my options to what I can do with Wix, but I haven't found anything and it's not something I'm going to get into right now.

推荐答案

有趣的问题.由于没有其他人回答:我不知道此功能的任何内置功能.我在 WiX 中快速浏览了一下,但我不记得在 商业工具 中看到过对此的支持.这很奇怪,因为部署到终端服务器似乎需要这样的东西?

Interesting problem. Since nobody else has answered: I am not aware of any built-in features for this. I had a quick look in WiX, and I can't recall having seen support for this in commercial tools either. This is quite strange, since deployment to terminal servers would seem to require something like this?

我们能问一下您要部署到什么环境吗?请再详细说明您的要求和需要它的理由?

Can we ask what environment you are deploying to? A little more details on your requirements and rationale for needing this?

如果您已经知道如何在代码中执行此操作,并且只是想检查是否有更简单的方法,或者您是否需要代码解决方案,那么您的问题并不清楚?

我总是喜欢使用本机代码进行部署.您的设置应该处理任何机器、任何状态、任何语言、任何操作系统版本和几乎任何操作系统版本.最少的依赖.

I always prefer native code for deployment. Your setup should handle any machine, in any state, in any language in any OS edition and just about any OS version. Minimal dependencies.

以下是一些链接.明天我得再看看.这有点乱:

Below are some links. I will have to have another look tomorrow. This is a bit messy:

  1. 本机 Win32:我认为 NetWkstaUserEnum 会工作,但它看起来像 LsaEnumerateLogonSessions 功能更好,如 CodeProject - 枚举登录会话(有古老的源代码可供下载).

  1. Native Win32: I thought NetWkstaUserEnum would work, but it looks like the LsaEnumerateLogonSessions function is better as described on CodeProject - Enumerating Logon Sessions (there is ancient source code to download).

终端服务器:似乎还有一个 查询工具 (serverfault)在终端服务器上(我从来没有试过了).

Terminal Server: There also seems to be a query tool (serverfault) on Terminal Servers (that I have never tried).

SysInternals:系统内部提供免费工具 PsLoggedOn,但在输出格式方面似乎并不理想.不过可能.

SysInternals: System internals offers the free tool PsLoggedOn, but it doesn't seem ideal with regards to output format. Possible though.

PowerShell/WMI:有 一些 PowerShell 脚本.我真的不喜欢 PowerShell 进行部署,但似乎很多人都在使用它们.我想这是未来.使用 WMI 时,结果在不同操作系统版本上似乎不一致.

PowerShell / WMI: There are some PowerShell scripts out there. I really dislike PowerShell for deployment, but lots of people seem to use them. I guess it is the future. Results seem inconsistent on different OS versions when using WMI it seems.

.NET Framework:Cassia,一个开源包装器.PInvoke Win32.

总是有 github.com 可以搜索.

这篇关于仅当打开多个会话时,如何在 wix 中安排重新启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆