Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ebubekirbastama/56399968cf81bada4d43f5fc07faa1a4 to your computer and use it in GitHub Desktop.
Save ebubekirbastama/56399968cf81bada4d43f5fc07faa1a4 to your computer and use it in GitHub Desktop.
using System;
using System.Diagnostics;
class Program
{
static void Main()
{
// İşlemi başlatma
Process process = new Process();
process.StartInfo.FileName = "notepad.exe";
process.Start();
Console.WriteLine("Notepad başlatıldı. Kapatmak için bir tuşa basın.");
Console.ReadKey();
// İşlemi kapatma
if (!process.HasExited)
{
process.CloseMainWindow(); // Kapatma penceresini gönder
process.WaitForExit(1000); // 1 saniye bekleyerek kapatmayı bekleyin
// İşlem hala çalışıyorsa, zorla kapat
if (!process.HasExited)
{
process.Kill();
}
}
Console.WriteLine("İşlem kapatıldı.");
Console.ReadLine();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment