Мои попытки:
Код: Выделить всё
string command = $"powershell -executionPolicy Bypass -Command \"Add-AppxPackage -Path '{path}'\"";
ProcessStartInfo startInfo = new();
startInfo.FileName = path;
startInfo.Arguments = path;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.CreateNoWindow = false;
startInfo.Verb = "runas";
Process? process = Process.Start(startInfo);
process?.WaitForExit();
Код: Выделить всё
An error occurred trying to start process 'C:\Users\MyUser\Documents\repos\AppServiceTest\UWPSample\bin\x64\Debug\net9.0-windows10.0.26100.0\win-x64\AppX\package47528147.msixbundle' with working directory 'C:\Users\MyUser\Documents\repos\AppServiceTest\UWPSample\bin\x64\Debug\net9.0-windows10.0.26100.0\win-x64\AppX'. The specified executable is not a valid application for this OS platform.Код: Выделить всё
string command = $"powershell -executionPolicy Bypass -Command \"Add-AppxPackage -Path '{path}'\"";
PackageManager packageManager = new();
Uri uri = new(path);
var deploymentOperation = packageManager.RequestAddPackageAsync(uri, null, DeploymentOptions.None, null, null, null);
DeploymentResult depoloymentResult = await deploymentOperation;
Код: Выделить всё
Access is denied.Код: Выделить всё
PackageManager packageManager = new();
Windows.Foundation.IAsyncOperationWithProgress deploymentOperation = packageManager.AddPackageAsync(
new Uri(path),
null,
DeploymentOptions.ForceTargetApplicationShutdown
);
DeploymentResult deploymentResult = await deploymentOperation;
Код: Выделить всё
Attempted to perform an unauthorized operation.Подробнее здесь: https://stackoverflow.com/questions/797 ... ng-c-sharp
Мобильная версия