Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
969 views
in Technique[技术] by (71.8m points)

windows installer - How to ScheduleReboot in wix only if several sessions are opened

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.

Thanks.

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.

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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?


It isn't quite clear from your question if you already know how to do this in code, and just want to check if there is an easier way, or if you want a code solution?

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. 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).

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

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

  4. 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.

  5. .NET Framework: Cassia, an open source wrapper. PInvoke Win32.

There is always github.com to search.



与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...