1

Please tell me how we can launch a desktop application or .exe file from a Windows store app using c#.

Any help would be really appreciated. Thanks in Advance!

Waqas Ahmed Khan
  • 343
  • 4
  • 21

1 Answers1

2

As stated in the comments, you can't directly launch an executable from a Windows Store App because of the sandboxed environment. However, you can use the launcher API to start an executable associated with a file. Therefore, you could create a file association between a custom file extension and the application you want to launch. Then, just use the launcher API to open a file having the custom file extension.

public async void DefaultLaunch()
{
   // Path to the file in the app package to launch
   string imageFile = @"images\test.png";

   var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);

   if (file != null)
   {
      // Launch the retrieved file
      var success = await Windows.System.Launcher.LaunchFileAsync(file);

      if (success)
      {
         // File launched
      }
      else
      {
         // File launch failed
      }
   }
   else
   {
      // Could not find file
   }
}
Dustin Cleveland
  • 618
  • 7
  • 17