0

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();

     });

3 Answers3

2

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

Aleks
  • 1,629
  • 14
  • 19
  • it give me this exception System.UnauthorizedAccessException: 'Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))' – Worawit Sudjitrak Aug 22 '19 at 07:03
  • @WorawitSudjitrak, yes, that is because per my answer, you are not allowed to use `ProcessStartInfo` from a UWP application; that is why it's an **UnauthorizedAccess**Exception. If you are referring to the use of `LaunchFileAsync` that is only for opening "documents"... e.g. you might launch a .txt file, and it will open the application associated with *.txt files; it's not for running an arbitrary program. – Aleks Aug 22 '19 at 07:44
  • LaunchFileAsync no ACCEEEDENiED I can Open .txt file but nothing happen when run .exe file and thanks for the quick answer – Worawit Sudjitrak Aug 22 '19 at 11:53
  • 1
    @WorawitSudjitrak, that's right, you can open a .txt file (probably opens Notepad), but in response to your original question, the answer still is... you cannot start another program (i.e. by launcing the .exe) from within UWP... Microsoft simply do not allow it, no matter which way you try. The only way you can launch another program is if it has a URI, or is the default program for a document type (like .txt) – Aleks Aug 22 '19 at 23:22
  • FullTrustProcessLauncher it's work fine to open another Installer.exe program in My Folder Assets accept TabTip.exe I think TabTip.exe is Problem – Worawit Sudjitrak Aug 23 '19 at 01:16
  • 1
    You can only use `FullTrustProcessLauncher` to launch components that are included in your own package. See https://learn.microsoft.com/en-us/uwp/api/windows.applicationmodel.fulltrustprocesslauncher, "Activate the full-trust Win32 component of an application from a Universal Windows app component in **the same application package**" – Aleks Aug 23 '19 at 01:22
2

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.

Martin Zikmund
  • 38,440
  • 7
  • 70
  • 91
  • thank you for good info and edit to perfect comment I can access target file but TabTip.exe not show in UWP like WPF I think UWP block Animation When program runing and not show – Worawit Sudjitrak Aug 24 '19 at 07:40
0

Make sure you edited the manifest file and add the extension for full trust process in the application.

Tom
  • 5
  • 4