Using Process.Start(#"C:\clip.mp4") will open video with default apps.
How can I open it with app "Movies & TV" (it's not default app) in C# Windows Form?
Necroposting here. I have had found out that you could treat the mswindowsvideo:// protocol as an application path on the command line.
Simply write on a command line or shell:
start "mswindowsvideo://" "<filePath>"
In your code, that would be: Process.Start("mswindowsvideo://", filePath);
For UWP you can use Launcher.
await Windows.System.Launcher.LaunchFileAsync(storageFile); //in my case this is .mkv file
Related
I need C# code to open the WhatsApp desktop application instead of open WhatsApp on the web.
I tried
Process.Start("https://web.whatsapp.com/send?phone=" + textBox1.Text);
but it opens WhatsApp on the web, instead of the WhatsApp Desktop application.
I want to open this link in desktop WhatsApp application
The desktop version of WhatsApp can be found in %LocalAppData%\WhatsApp\Whatsapp.exe.
You get the environment variable with
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
Use Path.Combine() to get the backslashes right when combining multiple paths.
Note that the executable above likely just starts another version of WhatsApp.exe. The latest version seems to be in the default key of the Registry at
HKEY_CLASSES_ROOT\whatsapp\shell\open\command
Starting point for an implementation: Registry.ClassesRoot.
Try using the whatsapp protocol:
var process = $"whatsapp://send?phone={textBox1.Text}";
Process.Start(process);
You can append the text argument to send a text:
whatsapp://send?phone=5555555555&text=hello
I need to register my app coded in c# on (at least) Windows10, in order to make it elegible to open URLs that are phone numbers on web browsers (preferably Chrome). If i'm not wrong, skype does/did it. Anyone knows how to do it?
Best regards and thanks in advance :)
UPDATE: Thanks to Oscar for his answer.
I've tried to put this keys:
HKEY_CLASSES_ROOT
tel
(Default) = "URL:tel Protocol"
URL Protocol = ""
DefaultIcon
(Default) = "c:\Program Files\Test\Test.exe,1"
shell
open
command
(Default) = "C:\Program Files\Test\Test.exe" "%1"
When I click a phone number with this scheme ("tel:nnnnnnnnn"), both Chrome and IE open a new windown allowing me to choose what app open, but my custom app doesn't appear :(
UPDATE 2: Seems like is not possible to do it on W10 (see comments bellow)
It involves writing some keys to register the tel: URI as handled by your application.
HKEY_CLASSES_ROOT
alert
(Default) = "URL:Alert Protocol"
URL Protocol = ""
DefaultIcon
(Default) = "alert.exe,1"
shell
open
command
(Default) = "C:\Program Files\Alert\alert.exe" "%1"
See this article for a full description:
https://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx
And this one about the tel: URI
https://www.rfc-editor.org/rfc/rfc3966
Seems like is not possible on W10...
The way that the applications can set itself as default ones has changed. Now the user is who decides what app should do the action... and the app has to be on the Windows Store...
See this article for a full explanation:
http://www.tenforums.com/software-apps/21303-how-do-you-set-protocol-association-standalone-exe.html
I have a question about opening a file stored in IsolatedStorage in my Windows Phone 8 C# app (in my case a file.txt file)
and opening it up in Office suite integrated in WP 8.
I have come up with this:
Windows.System.Launcher.LaunchUriAsync(new System.Uri("ms-word:" + (new Uri("file.txt", UriKind.Relative))));
It opens up Office Word with no problem, but it hangs at the "file does not exists" message and quits..
Any advice ? Thanks :)
Your Uri is wrong. It should be new Uri("ms-word:isostore:file.txt", UriKind.Absolute);
But still, the file can't be opened. Don't know why.
EDIT: This is not possible. You can only open office email attachments or office documents from OneDrive.
http://answers.microsoft.com/en-us/winphone/forum/wp8-wppersonal/open-word-and-excel-files-from-sd-card/23218c41-b72b-49df-9529-5e85a1912bc5
(I can find many answers for Windows Phone 7 which probably work Windows Phone 8/8.1 Silverlight, but not for Windows Phone [Store] 8.1)
While testing my application, I want to use a dummy server response. Since it's a large amount of data that includes quotation marks, I don't want to use a constant string and have to escape everything.
How can I read a text file that's included with my Windows Phone 8.1 application?
For this example, I have a file called sample-response.txt and its 'Build Action' properties is set to 'Content'.
var folder = Windows.ApplicationModel.Package.Current.InstalledLocation;
var file = await folder.GetFileAsync("sample-response.txt");
var contents = await Windows.Storage.FileIO.ReadTextAsync(file);
and if you want to double-check that it's been read ok
Debug.WriteLine(contents);
Is there a way to launch a desktop application from a Metro-style app on Windows 8? I'm trying to create some simple shortcuts to desktop applications to replace the desktop icons on the start screen, which look out of place.
I just need something super simple, preferably in C#, to open an application as soon as the app loads. I'm planning on making these shortcuts for some games, photoshop, etc, not anything I've made myself. They're also just for personal use, so I can use direct paths to applications like "C:\Program Files (x86)\Steam\steamapps\common\Skyrim\TESV.exe"
If you simply want to run a desktop application like (notepad, wordpad, internet explorer etc) then go through Process Methods and ProcessStartInfo Class
try
{
// Start the child process.
Process p = new Process();
// Redirect the output stream of the child process.
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = "C:\Path\To\App.exe";
p.Start();
}
// Exp 2
// Uses the ProcessStartInfo class to start new processes,
// both in a minimized mode.
void OpenWithStartInfo()
{
ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
Process.Start(startInfo);
startInfo.Arguments = "www.northwindtraders.com";
Process.Start(startInfo);
}
On Windows 8 Metro application i discovered this: How to Start a
external Program from Metro App.
All the Metro-style applications work in the highly sand boxed
environment and there is no way to directly start an external
application.
You can try to use Launcher class – depends on your need it may
provide you a feasible solution.
Check this:
Can I use Windows.System.Launcher.LauncherDefaultProgram(Uri) to invoke another metro style app?
Ref: How to launch a Desktop app from within a Metro app?
Metro IE is a special app. You cannot invoke an executable from Metro style apps.
Try this - I have not test yet but may be it will help you..
Launcher.LaunchFileAsync
// Path to the file in the app package to launch
string exeFile = #"C:\Program Files (x86)\Steam\steamapps\common\Skyrim\TESV.exe";
var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(exeFile);
if (file != null)
{
// Set the option to show the picker
var options = new Windows.System.LauncherOptions();
options.DisplayApplicationPicker = true;
// Launch the retrieved file
bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
if (success)
{
// File launched
}
else
{
// File launch failed
}
}
I found a solution which is suitable for me. I just made an empty textfile in my app and called it launcher.yourappyouwanttostart and then executed it with
Windows.System.Launcher.LaunchFileAsync("launcher.yourappyouwanttostart");
On the first startup it asks you for the assocation for this file and then you choose the exe file you want to run and from now on every time you execute this file, your app will be started.
I haven't actually tried if it works and it's not really a beautiful solution, but I guess Metro-style apps can launch a URI.
You could then create a desktop-program that is registered for a custom URI scheme that would then do the actual program launching.
What you can do is host external WCF service on your computer with separate installation and connect to it from metro style application using localhost. Then you can do pretty much anything including Process.Start.
I love simple things, so my solution was to use this:
Process.Start("explorer", "shell:AppsFolder\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe!App")
This will start the "new" Sticky Notes coming with Anniversary Update to Windows 10, but it works with all other "Metro" apps I tested.
To find the name of the metro app, from Windows Explorer you have to find it in shell:appsfolder using the AppUserModelId column.