I have the same problem. Can't catch the arguments from a running process.
private bool IsProcessRunning(string parameter)
{
// Check if a process with the name "NedaOPCService" is running
// without trying to access its StartInfo
var processes = Process.GetProcessesByName("NedaOPCService");
foreach (var process in processes)
{
// Here you can check if the process matches the expected parameter
// For instance, by matching the command line arguments (if possible)
if (process.StartInfo.Arguments.Contains(parameter)) // If process started with the right argument
{
return true;
}
}
return false; // No matching process found
}