Search code examples
uwpadbwindows-10-universal

Universal Windows Platform (UWP) hangs on Process.StandardOutput.ReadToEnd


When I run the method below the process.StandardOutput.ReadToEnd hangs and or returns empty. But the exact method run just fine using a console application. Is there something I am missing in UWP that needs added to this method?

  private void GetDeviceProperties()
    {
        Process process = new Process();
        process.StartInfo.FileName = "adb.exe";
        process.StartInfo.Arguments = "shell getprop"; 
        process.StartInfo.UseShellExecute = false;
        process.StartInfo.RedirectStandardOutput = true;
        process.StartInfo.RedirectStandardError = true;
        process.Start();
        //* Read the output (or the error)
        string output = process.StandardOutput.ReadToEnd();
        string err = process.StandardError.ReadToEnd();
        process.WaitForExit();
    }

Solution

  • UWP runs in a sandboxed environment, it seems that can not execute or launch directly exe from the UWP. You can try to launch a URI or file using the Windows.System.Launcher class though.