I have been trying to launch Microsoft Teams through C#, by launching the shortcut.
However I am getting an error:
System.ComponentModel.Win32Exception: 'The specified executable is not a valid application for this OS platform.'
This is my code:
using System;
using System.Diagnostics;
namespace OnlineLearning
{
internal class Program
{
static void Main(string[] args)
{
ProcessStartInfo teams = new ProcessStartInfo(@"C:\Users\cesq\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Microsoft Teams.lnk");
teams.CreateNoWindow = true;
teams.RedirectStandardError = true;
teams.RedirectStandardOutput = true;
teams.RedirectStandardInput = true;
Process foo = Process.Start(teams);
}
}
}
I have been following an example from this question: Run an application via shortcut using Process.Start()
And did as one answer suggested:
Process proc = new Process();
proc.StartInfo.FileName = @"C:\Users\cesq\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Microsoft Teams.lnk";
proc.Start();
Sadly this didn't work (gave the same error).
Also the accepted answer:
Setting UseShellExecute = false
was the problem. Once I removed that, it stopped crashing.
Didn't work for me, since I already have done what it suggested.
Also this question: How to run a shortcut did not help me as well, as it is not relevant to my example.
As well as this one: 'The specified executable is not a valid application for this OS platform
Now I am out of ideas, so I am asking for your help.