How to ScheduleReboot in wix only if several sessions are opened

前端 未结 1 1195
不思量自难忘°
不思量自难忘° 2020-12-22 01:41

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 could

1条回答
  •  被撕碎了的回忆
    2020-12-22 02:27

    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.


    • Powershell script to see currently logged in users (domain and machine) + status (active, idle, away)
    • https://serverfault.com/questions/32633/how-to-check-who-is-currently-logged-on-to-windows-workstation-from-command-line
    • https://blogs.msdn.microsoft.com/alejacma/2008/03/04/how-to-get-the-logged-on-user-with-wmi-vbscript/
    • WTSEnumerateSessions function
    • How do you use LsaEnumerateLogonSessions in C#?
    • https://gallery.technet.microsoft.com/scriptcenter/0e43993a-895a-4afe-a2b2-045a5146048a
    • https://serverfault.com/questions/598554/whats-the-best-way-to-see-logged-in-users-in-windows-server-2012

    0 讨论(0)
提交回复
热议问题