Hi
With the below code Video opens in browser but it does not get automatically run
C#
for (int i = 0; i < 4; i++)
{
vProcessId = Start("youtube.com/watch?v=MYojqnJ34g4?autoplay=1");
}
public static int Start(string processName)
{
var process =
Process.Start("msedge.exe", @processName);
return
process.Id;
}Thanks

Vishal YelveRank #178 · 13.6K reputationPosted Dec 1, 2022, 2:54 AM EST
Hi Ramco,
try this, I have tested and its working
class Program { static void Main(string[] args) { Console.WriteLine("Process Start!"); //var _process = new ProcessStartInfo(@"C:\Program Files\Internet Explorer\iexplore.exe", "youtube.com/watch?v=MYojqnJ34g4?autoplay=1"); //var _process = new ProcessStartInfo(@"C:\Program Files (x86)\Google\Chrome\Application\new_chrome.exe", "youtube.com/watch?v=MYojqnJ34g4?autoplay=1"); //Process.Start(_process); for (int i = 0; i < 4; i++) { RunVideo("youtube.com/watch?v=MYojqnJ34g4?autoplay=1"); } } public static void RunVideo(string videolink) { var _process = new ProcessStartInfo(@"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe", videolink); Process.Start(_process); } }Output
Ramco RamcoRank #462 · 5.4K reputationPosted Dec 1, 2022, 11:35 PM EST
Hi Vishal
How to close the browser window or kill the process after Video finishes.
Thanks
Vishal YelveRank #178 · 13.6K reputationPosted Dec 2, 2022, 4:12 AM EST
Hi Ramco,
you can close window using
WaitForExit(); and Close();
Process process = new Process(); var _process = new ProcessStartInfo(@"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe", videolink); //Process.Start(_process); process.StartInfo = _process; process.WaitForExit(); process.Close();