0

I want to launch a Win Form app from a metro style application.I tried Launcher.LaunchFileAsync(IStorageFile) | launchFileAsync(IStorageFile) API but the documentation says as metro application runs in a sand-boxed environment, many file types that contain executable code, for example .exe, .msi, and .js files, are blocked from launching.

I also tried Launcher.LaunchUriAsync(Uri, LauncherOptions) | launchUriAsync(Uri, LauncherOptions) method wherein you need to pass a URI and options to launch the application.But,apps cannot use the file:/// protocol to access files on the local computer.

Is there a way i can create and launch a batch(.bat)file from my metro style application so that it will somehow execute the commands in it and launch the launching app .exe with some options? Any help will be appreciated :)

AkshayJ
  • 771
  • 6
  • 15

1 Answers1

0

Metro/WinRT/UWP app can't directly launch another application. It can do only one of the following:

  1. Ask operating system to open specific file via some app registered in system for such file extensions. It is not about .exe files, but passing documents between applications. E.g. you can register your WinForms app in the OS to open .xyz files. Then you use the LaunchFileAsync API to open such file from your WinRT app. System will launch default application registered to open such files.
  2. Ask operating system to react to a specific protocol via some app registered in system for such protocol. It is not about file:/// protocol, but about other protocol to enable app-to-app communication and delegating actions. E.g. you can register your WinForms app in the OS to react to the myapp-xyz: protocol. Then you can use the LaunchUriAsync API to ask OS to launch some app that can deal with such protocol. System will launch default application registered to support that protocol.
Konstantin
  • 884
  • 6
  • 12
  • How you can register your WinForms app in the OS to open .xyz files.??Where are we supposed to register that? – AkshayJ May 06 '16 at 11:49
  • Here is what you need: http://stackoverflow.com/questions/69761/how-to-associate-a-file-extension-to-the-current-executable-in-c-sharp – Konstantin May 06 '16 at 11:51