C# exe uzantılı dosyayı çalıştırma ve durdurma...

deli kurt1453

Katılımcı Üye
13 Ağu 2011
368
0
Korriban
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace c_sharp_exe_calistirma_durdurma_islemi
{
public partial class exe_process_calistirma_kapama : Form
{
private System.Windows.Forms.Button btnStartProcess;
private System.Windows.Forms.Button btnStopAllProcesses;
private System.Windows.Forms.Button btnExeCalistir;
private System.Windows.Forms.Button btnCalisanExeleriKapat;

public exe_process_calistirma_kapama()
{
InitializeComponent();
InitializeMyComponent();
}

private static **** exe_Calistir()
{
//Çalıştırmak istenen işlemin exe uzantılı adresi
//belirtilerek process başlatılır
Process.Start(Environment.CurrentDirectory + "/program.exe");
}

private static **** exe_Kapat()
{
//kapatılmak istenen programı exe adı buraya yazılarak da exe durdurulur
Process[] process = System.Diagnostics.Process.GetProcessesByName("program");
if (process.Length > 0)
{
//Aynı process birden fazla çalışıyor olabilir
//Hepsini kapat
for (int i = 0; i < process.Length; i++)
{
//Eğer birden fazla aynı exr dosyası açılmışsa bu döngü ile bütün
// açlımış olan exe dosyaları durdurulur.
process.Kill();
}
}
}

private **** btnStartProcess_Click(object sender, EventArgs e)
{
// exe çalıştırma metodu
exe_Calistir();
}

private **** btnStopAllProcesses_Click(object sender, EventArgs e)
{
// exe durdurma metodu
exe_Kapat();
}

private **** exe_process_calistirma_kapama_Load(object sender, EventArgs e)
{

}

private **** btnExeCalistir_Click(object sender, EventArgs e)
{
// exe çalıştırma metodu
exe_Calistir();
}

private **** btnCalisanExeleriKapat_Click(object sender, EventArgs e)
{
// exe durdurma metodu
exe_Kapat();
}

private **** InitializeMyComponent()
{
this.btnStartProcess = new System.Windows.Forms.Button();
this.btnStopAllProcesses = new System.Windows.Forms.Button();
this.btnExeCalistir = new System.Windows.Forms.Button();
this.btnCalisanExeleriKapat = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// btnStartProcess
//
this.btnStartProcess.******** = new System.Drawing.Point(59, 56);
this.btnStartProcess.Name = "btnStartProcess";
this.btnStartProcess.Size = new System.Drawing.Size(75, 23);
this.btnStartProcess.TabIndex = 0;
this.btnStartProcess.Text = "Start Process ";
this.btnStartProcess.UseVisualStyleBackColor = true;
this.btnStartProcess.Click += new System.EventHandler(this.btnStartProcess_Click);
//
// btnStopAllProcesses
//
this.btnStopAllProcesses.******** = new System.Drawing.Point(166, 56);
this.btnStopAllProcesses.Name = "btnStopAllProcesses";
this.btnStopAllProcesses.Size = new System.Drawing.Size(145, 23);
this.btnStopAllProcesses.TabIndex = 1;
this.btnStopAllProcesses.Text = "Stop All Processes";
this.btnStopAllProcesses.UseVisualStyleBackColor = true;
this.btnStopAllProcesses.Click += new
System.EventHandler(this.btnStopAllProcesses_Click);
//
// btnExeCalistir
//
this.btnExeCalistir.******** = new System.Drawing.Point(59, 85);
this.btnExeCalistir.Name = "btnExeCalistir";
this.btnExeCalistir.Size = new System.Drawing.Size(75, 23);
this.btnExeCalistir.TabIndex = 2;
this.btnExeCalistir.Text = "Exe Çalıştırma";
this.btnExeCalistir.UseVisualStyleBackColor = true;
this.btnExeCalistir.Click += new System.EventHandler(this.btnExeCalistir_Click);
//
// btnCalisanExeleriKapat
//
this.btnCalisanExeleriKapat.******** = new System.Drawing.Point(166, 86);
this.btnCalisanExeleriKapat.Name = "btnCalisanExeleriKapat";
this.btnCalisanExeleriKapat.Size = new System.Drawing.Size(145, 23);
this.btnCalisanExeleriKapat.TabIndex = 3;
this.btnCalisanExeleriKapat.Text = "Çalışan Exe dosyalarını durdurma";
this.btnCalisanExeleriKapat.UseVisualStyleBackColor = true;
this.btnCalisanExeleriKapat.Click += new
System.EventHandler(this.btnCalisanExeleriKapat_Click);
//
// exe_process_calistirma_kapama
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(465, 178);
this.Controls.Add(this.btnCalisanExeleriKapat);
this.Controls.Add(this.btnExeCalistir);
this.Controls.Add(this.btnStopAllProcesses);
this.Controls.Add(this.btnStartProcess);
this.Name = "exe_process_calistirma_kapama";
this.Text = "EXE Çalıştırma Durdurma Programı";
this.Load += new System.EventHandler(this.exe_process_calistirma_kapama_Load);
this.ResumeLayout(false);

}

}
}
 

bekodark123

Uzman üye
31 Ocak 2012
1,402
0

Arkadaşım çok güzel şeyler paylaşıyorsun fakat nasıl yapıcağımızı anlatmıyorsun!
 
14 Kas 2009
68
0
çok uzun olmuş böyle anlatmamalıydın diye düşünüyorum
kısaca b.exe uzantılarını açmak için

System.Diagnostics.Process.Start("notepad.exe"); // eğer isterseniz site de açabilirsiniz
System.Diagnostics.Process.Start("www.google.com"); //varsayılan tarayıcıda açar
System.Diagnostics.Process.Start("chrome","www.google.com"); // chrome da açar (varsa :) )

eğer program yüklü ise çalışsın yüklü değilse çalışmasın derseniz

try
{
System.Diagnostics.Process.Start("chrome.exe");
}
catch
{
MessageBox.Show("Chrome yüklü değil");
}

try-catch-finally kullanımına bakmanızıda öneririm

ha bu arada ben habire System.Diagnostics yazmak istemiyorum derseniz using kütüphanesi olarak ekleyin
pek kısa olmadı ama umarım anlamışsınızdır :)
 
Üst

Turkhackteam.org internet sitesi 5651 sayılı kanun’un 2. maddesinin 1. fıkrasının m) bendi ile aynı kanunun 5. maddesi kapsamında "Yer Sağlayıcı" konumundadır. İçerikler ön onay olmaksızın tamamen kullanıcılar tarafından oluşturulmaktadır. Turkhackteam.org; Yer sağlayıcı olarak, kullanıcılar tarafından oluşturulan içeriği ya da hukuka aykırı paylaşımı kontrol etmekle ya da araştırmakla yükümlü değildir. Türkhackteam saldırı timleri Türk sitelerine hiçbir zararlı faaliyette bulunmaz. Türkhackteam üyelerinin yaptığı bireysel hack faaliyetlerinden Türkhackteam sorumlu değildir. Sitelerinize Türkhackteam ismi kullanılarak hack faaliyetinde bulunulursa, site-sunucu erişim loglarından bu faaliyeti gerçekleştiren ip adresini tespit edip diğer kanıtlarla birlikte savcılığa suç duyurusunda bulununuz.