Launch .exe app

ansalc 436 Reputation points
2020-05-06T14:53:25.747+00:00

How do I launch a .exe file that I created with VB.NET using UWP?

In VB.NET I would run

Dim app As Process = Process.Start(startInfo)

Thanks.

Universal Windows Platform (UWP)
{count} votes

Accepted answer
  1. Fay Wang - MSFT 5,196 Reputation points
    2020-05-08T06:47:07.727+00:00

    Hello,

    Welcome to Microsoft Q&A!

    You can use FullTrustProcessLauncher class to launch your .exe file from your UWP app. The methods in this class may only be called by packages that have the runFullTrust capability. To use this class, we recommend that you add a Windows Application Packaging Project to your solution. You can follow the steps below to launch your .exe file.

    1.You need to add "Windows Desktop Extensions" reference in your uwp project. Right click the References-> Add Reference->Universal Windows->Extensions-> add Windows Desktop Extensions".

    2.If your .net program and uwp app in the same solution, right-click your solution, add a Windows Application Packaging Project, then add your uwp app and .net program as Application references to the Packaging project to package them in one package. If they are in the different solution, you can copy .exe file to your UWP Application start up folder (for example: Assets folder), then you just need to reference your uwp in the Packaging project.

    3.Add the windows.fullTrustProcess extension in your Windows Application Packaging Project's manifest within the <Application> node.

     <Extensions>  
        <desktop:Extension  
              xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"  
              Category="windows.fullTrustProcess"  
              Executable="ConsoleApp2\ConsoleApp2.exe" />  
      </Extensions>  
    

    Note that, please specify path of your exe file located in the Executable property. If the .net program and uwp app in the same solution, input "ConsoleApp2\ConsoleApp2.exe". If you just copy the .exe file into your uwp app, input "Assets\ConsoleApp2.exe".

    4.Use the FullTrustProcessLauncher class to launch your .exe file.

    if (ApiInformation.IsApiContractPresent("Windows.ApplicationModel.FullTrustAppContract", 1, 0))  
    {  
        await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();  
    }  
    

    5.Run your Windows Application Packaging Project.


6 additional answers

Sort by: Most helpful
  1. Rishabh Pandey 6 Reputation points
    2020-05-06T16:28:37.853+00:00

    ***Hello @ansalc

    How to properly launch a UWP app ?

    https://stackoverflow.com/questions/41887366/how-to-launch-a-windows-universal-app-from-winform

    https://learn.microsoft.com/en-US/windows/uwp/launch-resume/handle-uri-activation?redirectedfrom=MSDN

    Above Both URLs are Better for You; Where is available and it's time minimizing case that's why I shared through URL.*

    *Because, We have done with more person that's why it's Better.***

    1 person found this answer helpful.

  2. Rishabh Pandey 6 Reputation points
    2020-05-06T17:20:17.563+00:00

    First Run Your Visula Studio " Run As Administrator )

    You can set the working directory like this but you can't run the directory itself only files or exe

    var startInfo = new ProcessStartInfo();

    startInfo.WorkingDirectory = //working directory

    Process proc = Process.Start(startInfo);

    You can use for opening file/directory

    public static void OpenFile(string path, bool isDirectory = false)
    {
    if (string.IsNullOrEmpty(path)) return;
    if ((isDirectory && Directory.Exists(path)) || (!isDirectory && File.Exists(path)))
    {
    ProcessStartInfo pi = new ProcessStartInfo(path);
    pi.Arguments = Path.GetFileName(path);
    pi.UseShellExecute = true;
    pi.WindowStyle = ProcessWindowStyle.Normal;
    pi.Verb = "OPEN";

            Process proc = new Process();
            proc.StartInfo = pi;
    
            proc.Start();
        }
    

    or

    Process.Start("explorer.exe",path);

    0 comments No comments

  3. Rishabh Pandey 6 Reputation points
    2020-05-06T17:21:43.477+00:00

    Once, Share the Snap of where you are coding for it if Possible

    0 comments No comments

  4. Rishabh Pandey 6 Reputation points
    2020-05-06T18:11:38.627+00:00

    *If It did not work.

    Just This URL How we should do the start the process with required Information just attached snap.

    https://learn.microsoft.com/en-us/windows/uwp/xbox-apps/automate-launching-uwp-apps?redirectedfrom=MSDN

    Attached Snap:8001-uwp-rishabh.jpg