0

I am installing applications programatically in an unattended fashion ( nothing special, just passing the paramters "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART" if exe, or "msiexec /qn /i ALLUSERS=1" while is an msi file ).

The problem is after installation suceded I want to open the application I've just installed. Then I am looking for a way to discover the main executable file of an application I've just installed.

I've tried monitoring harddisk and also checking on registry but I hasn't found anything robust and universal.

How can I achieve that?

forlayo
  • 1,371
  • 2
  • 13
  • 23
  • What have you checked in the registry? – Robert Harvey Feb 27 '20 at 19:18
  • In general you can't do this because there is no hard pattern that must be followed. What you need to do is find a different way to tackle the problem. – David Heffernan Feb 27 '20 at 19:21
  • @RobertHarvey I've been checking on list for uninstall at HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall but it's not exposing the path to exe file in most of cases. – forlayo Feb 27 '20 at 19:35
  • @DavidHeffernan what I am creating is somehow an "store" application, which allows to install apps into the system and also open them.. could you point me in right direction ? :) – forlayo Feb 27 '20 at 19:36
  • 2
    There is not direction, neither left nor right nor right nor wrong. This problem doesn't have a solution. – IInspectable Feb 27 '20 at 19:53
  • There's a collection of application paths at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\ – Robert Harvey Feb 27 '20 at 20:12
  • If I repeat what I said before, will you read it this time? – David Heffernan Feb 27 '20 at 20:37
  • @RobertHarvey thanks I'll check if this could improve my solution. – forlayo Feb 27 '20 at 20:45
  • @DavidHeffernan I have asked again as you pointed to find a different way to tackle the problem. Apologizes if I have missunderstood your answer, then I'll keep the point of there's no a way to do this and maybe I need to ask, apart of the installer, to provide the entry point or so.. Thanks. – forlayo Feb 27 '20 at 20:48

1 Answers1

0

I've found a suitable way, I hope this could help anyone else.

There's an special hidden shell object in Windows 10 who list all the applications (UWP and regular) that gets open in this way:

  • Win + R
  • Put Shell:AppsFolder and execute it.

Then it's a question of getting the list there programatically and checking what have changed after installation.

This is achieved in this way (It's needed this nuget package):

var appsFolderId = new Guid("{1e87508d-89c2-42f0-8a7e-645a0f50ca58}");
IKnownFolder appsFolder = KnownFolderHelper.FromKnownFolderId(appsFolderId);
foreach (var app in appsFolder)
{
  Console.WriteLine($"{app.Name} {app.ParsingName}");
}

app.Name is the name of the app, and app.ParsingName is the name that can be used to open the application using this:

System.Diagnostics.Process.Start("explorer.exe", @" shell:appsFolder\" + app.ParsingName);

If needed, you can get the icon of the app through this property:

app.Thumbnail.ExtraLargeBitmapSource

Credits to this answer for the solution.

Then now is a question of storing the current list, install the new app and check changes on that list after. Also as the answer suggests; you can listen for changes on that shellobject to get notified while the change is effective, with this:

ShellObjectWatcher watcher = new ShellObjectWatcher(appsFolder, false);
watcher.AllEvents += <Your_events_handler>;
watcher.Start();
forlayo
  • 1,371
  • 2
  • 13
  • 23