简体   繁体   中英

Process.Start() Open exe file nothing hapen in UWP

no Error just nothing happen and file target still there in my path

public void keyboard(){

    ProcessStartInfo touchkey = new ProcessStartInfo(@"C:\Program 
    Files\Common Files\microsoft shared\ink\TabTip.exe");
    touchkey.WorkingDirectory = @"C:\";
    touchkey.WindowStyle = ProcessWindowStyle.Hidden;
    Process.Start(touchkey);
 } 

Update

The suggested solution threw a `UnauthorizedAccessException`:

var path = @"ms-appx://C:/Program Files/Common Files/microsoft 
shared/ink/TabTip.exe";
var file = await 

Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(path); await Windows.System.Launcher.LaunchFileAsync(file);

Update2

I try to use FullTrustProcessLauncher it's work fine but like code before Keyboard tabtip.exe not show I dont know what should I do

   await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
     {
      FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();

     });

Without TabTip.exe

I recognize you are trying to show the on-screen keyboard judging by the path of the exe . I suggest a better approach would be to trigger the new touch-enabled keyboard which is easily possible without additional hassle from UWP with InputPane API :

var pane = InputPane.GetForCurrentView();
pane.TryShow();

With TabTip.exe

If you prefer the older on-screen keyboard for some reason, you have two problems with your existing code.

Firstly, ms-appx: scheme is used to refer to files at the application installation path. The path you require is an absolute path, so you can't use it there.

Secondly, as this is an arbitrary path on the hard drive, you don't have access to it directly (as UWP apps run in a sandbox and can't access the filesystem directly for security reasons). To access the file, you will need to declare the broadFileSystemAccess capability, which will then allow you to initialize the StorageFile instance. You can check for example this SO question to learn how to do just that.

Note: I don't have my VS PC around so I can't say for sure if this will allow you to launch the executable or not, as that seems like an additional permission which may not be granted. In case this fails, I strongly recommend the first solution.

UWP applications are sandboxed and cannot launch other processes directly due to security restrictions.

The only way to launch other applications is if those applications have a URI registered, or an application is a default handler for a particular file type.

In those instances, you can use methods such as LaunchUriAsync or LaunchFileAsync

确保已编辑清单文件,并在应用程序中添加了用于完全信任过程的扩展名。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM