Creating a process in ASP.NET and checking TotalProcessorTime

From: Juerg Staub (juerg.staub@object-soft.ch)
Date: 08/13/02


From: juerg.staub@object-soft.ch (Juerg Staub)
Date: 13 Aug 2002 14:46:28 -0700


Hi,

I am creating a process in a C# class like the following:

code> ProcessStartInfo sti = new ProcessStartInfo();
code> sti.FileName = "c:\\windows\\notepad.exe";
code> sti.CreateNoWindow = true;
code> sti.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
code> this.process = Process.Start(sti);
code> this.process.Exited += new EventHandler(this.processDied);

When I try to get the processor time with

code> TimeSpan ts = this.process.TotalProcessorTime

I receive a System.InvalidOperation exeception. The process is created
as the NETWORK SERVICE user. I tried with impersonate and/or changing
the processModel user to system with no help. The notepad.exe is only
an example. The real process will be a windowless program.

The box is .NET server with IIS6.

Any help appreciated.

Juerg


Quantcast