0

We do an update of our application, which consists of a system service and a UI application. The UI application is running under each user logged in to the system. It is implemented by placing a .lnk shortcut under the C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup folder.

The sequence of update is:

  1. stop service & UI app for all users
  2. update binary files
  3. restart the service and UI app

The question is, how to properly restart the UI application if the update was performed in the context of the SYSTEM account (session 0) and the system has a couple of logged-in users?

Windows starts the UI application on each user login, but if it was terminated, the next restart will be on the next user login.

Does Windows have some functionality like restart startup application?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
tens0r
  • 55
  • 3
  • A .lnk file is just a shortcut, not the application (binaries). Binaries may be locked but the shortcut shouldn't (or you need to retry a bit). What do you mean by "restart startup application"? – Simon Mourier Jan 03 '23 at 16:41
  • 2
    The service can enumerate logged in user sessions with WTSEnumerateSessions(), get each session's user token with WTSQueryUserToken(), and run the UI app in each session with CreateProcessAsUser() – Remy Lebeau Jan 03 '23 at 19:04
  • yes WTSQueryUserToken is an approach that I've implemented, btw I'm wondering if windows have build-in functionality that does not require manual enumeration, just like "startStarupApp(name string)" – tens0r Jan 04 '23 at 07:29
  • 1
    How is the UI app registered to start at user logon? Using "Run" registry key, using a scheduled task, ...? – zett42 Jan 04 '23 at 16:00
  • It's enough to start the application using [CreateProcessAsUser](https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessasuserw). [Application Recovery and Restart](https://learn.microsoft.com/en-us/windows/win32/recovery/application-recovery-and-restart-portal) can restart an application if an installer updates a component of the application. Note that to support automatic application restart after an installer updates an application, both the application and installer need to be authored appropriately. – YangXiaoPo-MSFT Jan 05 '23 at 03:02

0 Answers0