1

I want to find out recent/frequent items from jumplist of any app. I know that we can do this using IApplicationDocumentLists interface. But we need appUserModelId for that. So now my problem is to find out appUserModelId for any app, given its exe path. Any help will be highly appreciated.

Shashank
  • 77
  • 1
  • 4

2 Answers2

6

AppUserModeIDs are not part of the EXE file itself, so it is not enough to just have the path to the EXE file. AppUserModeIDs are assigned while the EXE is running, and they can be assigned on process-wide or per-window basis.

To query a process's explicit AppUserModeID, you would have to inject code into that process and have it call GetCurrentProcessExplicitAppUserModelID(), then use an IPC mechanism to send the value back to your main app.

To query a window's explicit AppUserModeID, you can use SHGetPropertyStoreForWindow() to get the window's IPropertyStore interface, and then call IPropertyStore.GetValue() specifying PKEY_AppUserModel_ID as the property key.

Note that in either case, these functions only work for explicit AppUserModeIDs. They do not work for implicit AppUserModeIDs that are assigned by Windows if an app does not assign an explicit AppUserModeID for itself. This is clearly stated in the documentation:

Application User Model IDs (AppUserModelIDs)

Some applications do not declare an explicit AppUserModelID. They are optional. In that case, the system uses a series of heuristics to assign an internal AppUserModelID. However, there is a performance benefit in avoiding those calculations and an explicit AppUserModelID is the only way to guarantee an exact user experience. Therefore, it is strongly recommended that an explicit ID be set. Applications cannot retrieve a system-assigned AppUserModelID.

Update: in Windows 8, Microsoft added a new GetApplicationUserModelId() function:

Gets the application user model ID for the specified process.

You can use that instead of injecting code to call GetCurrentProcessExplicitAppUserModelID(). I have not tried it yet, but I suspect it returns the current AppUserModeID regardless of how it is assigned (explicit or system-assigned).

Remy Lebeau
  • 454,445
  • 28
  • 366
  • 620
  • Thanks for your input. So is there no other way of getting jumplist of any app ? Because i tried IPropertyStore way of getting appUserModelId and then jumpList, but i can't get because most of these applications had not defined explicit userModelId. So this method will not work for me. I want to get jumplist of any application. – Shashank Jan 17 '15 at 07:48
  • There is no way to get a jump list without an AppUserModeID, and there is no way to get an AppUserModeID that is implicitly created by Windows (unless you reverse-engineer Windows to figure out the heuristic algorithms it uses to create its implicit AppUserModeIDs). – Remy Lebeau Jan 17 '15 at 17:45
  • Thank you very much for your input. it was really helpful – Shashank Jan 17 '15 at 19:09
  • You don't need an AppID just to run an app. If you know the path to the `.exe`file, use `CreateProcess()` or `ShellExecute()` to run the `.exe` file directly. – Remy Lebeau Aug 18 '15 at 15:25
  • Really? Did you try that? And why do I get an Access Denied when I double click Calculator.exe in Windows 10? In FileExplorer I can't even open the folder "WindowsApps" -> Access Denied even with an Admin account that has read and execute permission. It seems that it is not as simple as you say. – Elmue Aug 18 '15 at 16:01
  • Yes, it is that simple, and has been that simple for many years. Clearly, you don't have your user account permissions configured correctly if you can't even run the Calculator. – Remy Lebeau Aug 18 '15 at 16:10
  • I have read and execute permission. I don't know what should be wrong with that. Apart from that it is no way for me to tell my users that they first must adjust their privileges before my application can programmatically start a StoreApp application! And when I start Calculator.exe from a service with SYSTEM/NT AUTHORITY I get error 193 "%1 is not a valid Win32 application". So your answer does definitely not apply to Windows 10. – Elmue Aug 18 '15 at 16:47
  • Apart from that it doesn't work on Window 8 neither. If I double click for example WebCam.exe I get the same errors. And the majority of the Store Apps does not have even an EXE file in it's folder. For example in Bing.Sports there are only DLLs and other files but no exe. Conclusion: Store Apps cannot easily be started. The reason is that they run in an application host and not directly. – Elmue Aug 18 '15 at 17:16
  • You did not say anything earlier about launching Store apps. That is very different than launching standard Win32 apps. See [How do I launch a Windows Store application programmatically?](http://stackoverflow.com/questions/17944718/) – Remy Lebeau Aug 18 '15 at 17:17
  • So what you wrote above: "You don't need an AppID just to run an app" is wrong. – Elmue Aug 18 '15 at 17:20
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/87298/discussion-between-remy-lebeau-and-elmue). – Remy Lebeau Aug 18 '15 at 17:27
0

You cannot obtain the AppUserModelId from the Exe path. This is not possible.

But you can read my posting how to enumerate all AppUserModelId's of all installed StoreApps for the current user: How to enumerate the installed StoreApps and their ID in Windows 8 and 10

Community
  • 1
  • 1
Elmue
  • 5,679
  • 41
  • 53