How can I run a command in windows store app?

后端 未结 1 1116
野趣味
野趣味 2021-01-28 05:20

I need to run a command from windows store app?

the command is something like this : java -jar abc.jar

How can I do that?

EDIT :

相关标签:
1条回答
  • 2021-01-28 06:09

    The app container blocks this behavior for Store apps.

    First of all, you're attempting to obtain a StorageFile through your package InstalledLocation folder, which will not work. InstalledLocation is a StorageFolder, and its GetFileAsync looks for files only within that immediate folder. This is why it's returning file not found.

    The API that takes an arbitrary path is Windows.Storage.StorageFolder.GetFileFromPathAsync. However, your ability to access files is limited by the app container. You can access files in your package folder or app data locations by default, or the various media libraries if you've declared access in the manifest, but otherwise you have to go through the file picker so the user is aware of what you're doing and can grant consent. Simply said, this is the only way you'll get to a file in a location like c:\data. You can play with this using Scenario 1 of the Association launching sample and the "Pick and Launch" button.

    If you can get that access permission, then in you'll be able to launch a file if it's not a blocked file type. Data files (like a .docx) that are associated with another app work just fine, but executables are wholly blocked for what should be obvious security reasons. You can try it with the sample I linked to above--pick .bat, .cmd, .exe, .msi, etc. and you'll see that LaunchFileAsync fails.

    Also note that the other launcher function, LaunchUriAsync, also blocks file:/// for the same reasons.

    0 讨论(0)
提交回复
热议问题