Hi sthsyed,
Refer the below code. I have provided you the logic. So you need to change the code as per the file path you are passing thh the process.
C#
Process process = new Process();
// Pass your exe file path here.
string path = @"D:\Users\Dharmendra\Speak.exe";
string fileName = Path.GetFileName(path);
// Get the precess that already running as per the exe file name.
Process[] processName = Process.GetProcessesByName(fileName.Substring(0, fileName.LastIndexOf('.')));
if (processName.Length > 0)
{
Response.Write("Process already running");
}
else
{
process.StartInfo.FileName = path;
process.Start();
}
VB.Net
Dim process As New Process()
' Pass your exe file path here.
Dim path As String = "D:\Users\Dharmendra\Speak.exe"
Dim fileName As String = System.IO.Path.GetFileName(path)
' Get the precess that already running as per the exe file name.
Dim processName As Process() = process.GetProcessesByName(fileName.Substring(0, fileName.LastIndexOf("."c)))
If processName.Length > 0 Then
Response.Write("Process already running")
Else
process.StartInfo.FileName = path
process.Start()
End If
You can also get all the running process using the below code.
C#
Process[] processlist = Process.GetProcesses();
foreach (Process theprocess in processlist)
{
Response.Write(string.Format("Process: {0} ID: {1}</br>", theprocess.ProcessName, theprocess.Id));
}
VB.Net
Dim processlist As Process() = Process.GetProcesses()
For Each theprocess As Process In processlist
Response.Write(String.Format("Process: {0} ID: {1}</br>", theprocess.ProcessName, theprocess.Id))
Next