system.diagnostics

How did my process exit?

From C# on a Windows box, is there a way to find out how a process was stopped? I've had a look at the Process class, managed to get a nice friendly callback from the Exited event once I set EnableRaisingEvents = true; but I have not managed to find out whether the process was killed or whether it exited naturally? ...

C# :How do I know when the last OutputDataReceived has arrived

Hello, I have a System.Diagnostics.Process object in a program targetted at the .Net framework 3.5 I have redirected both StandardOutput and StandardError pipes and I'm recieving data from them asynchronously. I've also set an event handler for the Exited event. Once I call Process.Start() I want to go off and do other work whilst I ...

How do you run a program you don't know where the arguments start?

The subject doesn't say much cause it is not easy to question in one line. I have to execute a few programs which I read from the registry. I have to read from a field where somebody saves the whole paths and arguments. I've been using System.Diagnostics.ProcessStartInfo setting the name of the program and its arguments but I've found a ...

System.Diagnostics: How to log using an identity

I have implemented tracing based on System.Diagnostics. I am also using a System.Diagnostics.TextWriterTraceListener, and hooked the whole trace up to a MOSS 2007 Web Application. The trace for some reason is trying to (a) create the log file, and/or (b) write to the log file using the user that is currently browsing the SharePoint s...

User32's ShowWindow doesn't act as expected

I am using the ShowWindow method from User32 to hide a window (cmd.exe) from the user (mainly to prevent them from closing it). When the user opens the form, the process is started, and hid, then when the form is closing the process is killed. However, when the form is opened again, it doesn't hide the window (and sometimes doesn't the f...

How to translate MS Windows OS version numbers into product names in .NET?

How to translate MS Windows OS version numbers into product names? For example, in .NET the following two properties could be used to work out that the product is MS Windows Vista Ultimate Edition : Environment.OSVersion.Platform returns Win32NT Environment.OSVersion.Version returns 6.0.6001.65536 ...

.NET Process Start Process Error using credentials (The handle is invalid)

I have an Windows Form application that supplies the User Name, Domain, and Password to the StartInfo, and it throws this: System.ComponentModel.Win32Exception: The handle is invalid at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() When I allow the credentials ...

Check if a process is running on a remote system using C#

I am trying to check if a process is running on a remote system. I am using the following code: string procSearc = "notepad"; string remoteSystem = "remoteSystemName"; Process[] proce = System.Diagnostics.Process.GetProcessesByName(procSearch, remoteSystem); However, when I try to run the code, I get the following error: "Couldn't c...

Process.WaitForExit() causes a NullReferenceException

The following code causes a NullReferenceException tStartParameter = String.Format(tStartParameter, tTo, tSubject) tProcess = Process.Start(New ProcessStartInfo(tStartParameter) _ With {.UseShellExecute = True}) tProcess.WaitForExit() tStartParameter is: https://mail.google.com/?view=cm&fs=1&tf=1&[email protected]

How can I programmatically limit my program's CPU usage to below 70%?

Of late, I'm becoming more health oriented when constructing my program, I have observed that most of programs take 2 or 3 minutes to execute and when I check on the task scheduler, I see that they consume 100% of CPU usage, can I limit this usage programatically in code? This will certainly enable me to run multiple programs at a given ...

Difference between using Trace and TraceSource

Hi, Anyone knows the difference between System.Diagnostic.Trace and System.Diagnostic.TraceSource? I've been using Trace for most of my projects and I just happen to found out about TraceSource the other day. They seems to offer similar API, is one better than the other? ...

How to get trace output added to context.response in httphandler?

I've enabled trace pageoutput="true" in my web.config and I like the easy way it provides of seeing all this stuff at the bottom of the page. I'd like to get the same output from trace at the bottom of the output from my httphandler. Is there a way to dump out the same trace info via code that would follow this code: public class Uplo...

Autorun a CD from Process.Start

What is the closest way to emulate autorunning a CD (or other media, I guess) using Process.Start and ProcessStartInfo? I've tried obvious things like: // Just opens the folder Process.Start("F:"); // Ditto Process.Start(new ProcessStartInfo("F:") {UseShellExecute = true}); // Throws System.ComponentModel.Win32Exception: No applicati...

performance counters and their base link

with some performance counters they are compriseed of 2 counters the actual counter and a "base" counter used for calculations. The question is, in .net, is there any easy way to get the linked base counter. from the web I've seen them linked by name but that only works sometimes. Any ideas appreciated. ...

How to get the output of a System.Diagnostics.Process?

I run ffmpeg like this: System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo = new System.Diagnostics.ProcessStartInfo(ffmpegPath, myParams); p.Start(); p.WaitForExit(); ... but the problem is that the console with ffmpeg pops up and disappears right away, so I can't get any feedback. I don't even know if the p...

System.Diagnostics.Debug.WriteLine in production code

I should probably know this already, but I'm not sure and I don't see it documented. I use System.Diagnostics.Debug.WriteLine quite often during the development process to be able to track changes to variables or exceptions as I'm debugging the code. This is meant to make development and understanding what's happening easier only durin...

Is my process waiting for input?

I am using the Process class to run an exe. The exe is a 3rd party console application that I do not control. I wish to know whether the process is waiting for input on the command line. Should it make any difference, I intend to kill the application should it be waiting for input. There are suitable events for when there is output f...

Event Logging IPAddress does not always resolve

Hey Stack Overflow, I am hooking the Security event log with System.Diagnostics.Eventing.Reader.EventLogWatcher class, and I am watching Event ID 4625 on a 2008 server box, for incoming failed logins (RDP, specifically). The log capturing is working fine, and I am dumping the results into a queue for related, later processing. However,...

C# System.Diagnostics.Process verb issue

I have a Windows Application written in C# VS 2008. The purpose of this application is to convert any file to PDF files. I have found code that works on converting the files however there is a small issue that I am coming across. First here is the code: private void PrintToAdobePDF(string strInputFilePath) { Proces...

C# System.Diagnostics.Process.Start() parameters

Anyone know where a computer keeps what parameters it can accept through this function? For example, I'd like to know what I can send to Winword.exe (Microsoft Word). Or is there an online list of what programs work here? ...