What's the equivalent of the System.Diagnostic.Process on WinRT (C#)? - c#

I need to launch a couple of commands from my WinRT application, like if it were a Command Console, in order to do this, on not WinRT apps the class to be used is System.Diagnostic.Process but on Win RT his class is not available, is there any equivalent class or method that i could use?
Thanks in advance :)

Windows Store Apps cannot launch other processes directly, as Marylin already said. You can only use Launcher.LaunchFileAsync to launch the default application for the file type (file ending) the passed file has. Using this you could define a self-defined file type like .process in Windows and set its handler application to a windowless desktop application you write. The desktop application reads the process file which has the path to the application stored that is to start and launches it using Process.
This trick would certainly fail the certification but may be useful in apps you deploy to businesses skipping the Store.
A problem would be that the Windows Store App is set to the background if a Desktop application is launched. I think this is one reason that Microsoft does not allow it for certified apps.

You cannot do that from a Windows Store application - those are sandboxed and do not have access to other processes. More details here.

Related

Detecting programmatically whether a specific UWP app is installed on system

Without going through Windows Registry, is there a quicker way to detect programmatically whether a specific Universal Windows Platform (UWP) app is installed on a system? App will be installed through Windows Apps Store and its installation need to be verified from a Winform program written in C#. But the language doesn't matter.
You should be able to use PackageManager.FindPackage or PackageManager.FindPackageForUser to see if the target package is available universally or for the specific or current user.
See Calling Windows 10 APIs From a Desktop Application for info on how to call this from your WinForms app.
Also check out the Enumerate app packages by user SID sample which demonstrates enumerating app packages from a C# console app. The project used is out of date (it's for VS2013), but the overall code flow should still work.
Depending on your specific scenario (why do you need to know this and what will you do with that information?) there may be better ways for your specific use case. For example: you asked elsewhere about launching a UWP app. If you define and launch a protocol for the app you don't need to check if it's already there first as the protocol launch will offer to look for the app in the store if it's not installed.

Run External exe from UWP app, workaround sandboxed mode

I have a program where i want to have the ability to launch a local application (for example Spotify) from my UWP App. I have searched the web for a solution as (Process.Start()) doesn't work. As i have understood the UWP applications is kind of sandboxed for saftey and stability reasons. But is there a (simpel) way to work around this.
I only want the ability to start and close a program inside my own frame/Window. No need to interact/send/recive data between my applications and the external program
That is not possible with all apps. Some desktop apps handle protocol launches and that can be a way of launching another app. Spotify actually has a protocol registered so you could do this to launch it:
await Launcher.LaunchUriAsync(new Uri("spotify:"));
I have a program where i want to have the ability to launch a local
application (for example Spotify) from my UWP App.
You can utilize Windows.System.ProcessLauncher API.
Here is a sample about how to launch an external process (exe) from a Universal Windows Platform (UWP) app you can reference.
Make sure add systemManagement capabiity.
For more information reference Process​Launcher.

Get process info (window title) by process ID

Quick question ... Microsoft removed support for Process class in Metro Apps. How to get Window title of known Process ID?
I literally Google'd the whole internet for answer without success :/
Microsoft has not supported the Process class in Windows Store apps.
Windows Store Apps are not supposed to have that kind of access, unlike desktop apps. Besides, if you have Windows RT and you're running a Metro App that uses the Process class, you're not going to be able to because Windows RT does not run desktop apps.
Sorry to disappoint you, but if you need to do that, create a desktop app (not able to run on Windows RT).
P.S. They're called Windows Store apps now (not Metro) due to a lawsuit.

Launch Windows Explorer from Metro style app

I would like to download a file to the DownloadsFolder in a Windows Store App. And then I'd like to bring up a Windows Explorer open on the DownloadsFolder (actually on the folder I create in the DownloadsFolder)
But I can't figure out how to do it.
This stackoverflow question Launching a Desktop Application with a Metro-style app suggests using Launcher.LaunchUriAsync. But the documentation claims:
You cannot use this method to launch a URI in the local zone. For example, apps cannot use the file:/// protocol to access files on the local computer. Instead, you must use the Storage APIs to access files.
And indeed, I was trying to use the "file:" protocol to bring up the explorer window. When I did try this mechanism Launcher.LaunchIUriAsync fails.
If the browser can do this, why can't I?
Is there a way for me to bring up windows explorer, or is that outside the real of possibility?
I don't think you can launch the Windows Explorer from metro. One thing you can use, however, is the File Picker.
http://code.msdn.microsoft.com/windowsapps/File-picker-app-extension-0cb95155
If you're willing to have some non-Windows Store components in your solution, there is a workaround for this. Although you can't launch a process directly, you can always run a HTTP listener inside a Windows service which listens for commands from your sandboxed Windows Store (Metro-style) app and launches Explorer (or any other process) for you. A trivial way to do this would be a Web API service inside a Windows service - just implement the GET action in your controller and have arguments for the executable to launch and optionally executable arguments as well.
This is kind of doing an end-run around the sandbox security, though, so you might want to have a tailored Web API instead which just launches a pre-packaged set of apps (like Explorer or one of your own apps).
Of course, for consumer apps this is not a good solution because you can't just install everything from the Windows Store. For LOB apps, though, it's not a bad compromise because you typically have more control over the environment. This is a good way to surface some metrics or other data into a live tile and have your desktop app launch when the tile is clicked. Whether or not this makes for a good user experience is a totally different conversation.
BatRT allows you to run batch file commands from WinRT applications. It utilizes URI calls. This can be used to open up applications or perform file operations.

Managing Download File By Using Win Services?

i am trying to make a window service that will monitor and manage download files from different web pages.....
can some one give me direction where should i start looking ......
currnetly i am trying to understand nagios monitoring windows http://nagios.sourceforge.net/docs/3_0/monitoring-windows.html in which they have given some details related to my work
the thing which i have to do is ,
monitor and manage download file
give a custom name to the download file at saving time
and display save dialog box for specifying the location
currently i am making window service on Win XP but i would like this service to run also on other Win Operation Systems too so do i have to do some special setting for making it compatiable with other windows operation systems ??
thanks in advance
Regards,
NewbieFreak
A .NET windows service will run on any windows platform that supports and has the runtime your service targets installed on it.

Categories

Resources