Are apps launched by URI in a UWP app also sandbox

2020-04-21 01:37发布

问题:

I inherited a UWP app and was asked to add a button to launch a 3rd party application. The 3rd party application is built with Qt and has an exe as the main program that launches a second exe that acts as a service. The UWP app is to be run on tablets running Windows 10.

I created an installer that adds registry values for the URI for the 3rd party application so I can do URI activation (LaunchUriAsync method). If I change the target of the URI to a different application it works fine, so I know the URI is setup properly.

When I hit the button the 3rd party application does not open. I used ProcMon to see what was happening and confirmed that it begins opening but then stops before launching the second exe. Nothing is written to the event log because that would be too helpful.

I haven't found any documentation about this, but I have to assume that an application launched from a UWP app is also sandboxed. Does anyone know if this is correct? I'm not sure what to do other than rebuild the app as WPF or something and that isn't very appealing.

回答1:

The answer to your question is: no, that they are not being run sandboxed.

Launching an app that runs in fulltrust from a UWP via protocol is a supported scenario (e.g. that's how composing email works if Outlook is your default mailto: provider).

I suspect that is something missing in your protocol registration, or how you invoke it, but there is not enough detail in the question to troubleshoot this.



回答2:

I was able to launch my 3rd party application by making a new console application for the UWP to launch that then starts a new process for it.

Console app is just this:

var proc = new Process(); 
proc.StartInfo.FileName = filePath; 
proc.StartInfo.WorkingDirectory = Path.GetDirectoryName(filePath); 
proc.Start(); 
proc.WaitForExit(); 
var exitCode = proc.ExitCode; 
proc.Close(); 

The "WorkingDirectory" was required and from the UWP I don't see a way to set that.