Reputation: 152
I started a new project with WinUI in UWP. I thought that starting processes with Process.Start doesn't work or is not supported because of security reasons, but when I started the following code snippet it started working somehow.
The question is now, why does it work, or is are there any restrictions e.g. that I cannot deploy the .exe that is included in my project to the Microsoft Store?
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
private async void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
Process.Start(@"Tools\example.exe", "--help");
}
}
Exectuable included in project (Build Action = None and Copy to Output Directory = Copy if newer):
Upvotes: 0
Views: 971
Reputation: 169190
You can run an .exe
that is included in the package using the Process.Start
API in .NET on the Fall Creators Update of Windows 10 and later versions.
Check the target Min Version
of your app under Project->Properties->Application in Visual Studio. It should be set to Windows 10 Fall Creators Update (10.0; Build 16299)
or a newer version.
You should be able to publish your app it the store as long as the external component (example.exe
) is certified separately or is compliant with the Windows App Certification Kit.
Upvotes: 1
Reputation: 32775
but when I started the following code snippet it started working somehow.
I tested with your code, it throw exception The system cannot find the file specified
, it does not work in my side. Could you mind share a sample to explain this.
why does it work, or is there any restrictions e.g. that I cannot deploy the .exe that is included in my project to the Microsoft Store?
In general, we often launch the win32 app from uwp with FullTrustProcessLauncher. But you need to enable runFullTrust Restricted capability for package project. Restricted capabilities are intended for very specific scenarios. The use of these capabilities is highly restricted and subject to additional Store onboarding policy and review. Note that you can sideload apps that declare restricted capabilities without needing to receive any approval. Approval is only required when submitting these apps to the Store.
Upvotes: 1