|
everything looked like its working right but i ran into a small snag
I ran it on a terminal server ( where many people log on to run apps) and the proccess killed EVERY proccess with the name i wanted (not good)
Here is an example of what i see in taskman
Red is the scope of what it killed I am hopeing to narrow it down to who ever runs it ( in this case me rbarbrow) in BLUE
[IMG]http://i13.tinypic.com/6bcvou9.png[/IMG]
|
|
|
|
|
Hello,
Sorry for the late response!
Maybe the process member "MachineName" helps you to find the wright process.
All the best,
Martin
|
|
|
|
|
1.
int ThisSession = System.Diagnostics.Process.GetCurrentProcess().SessionId;
2.
int thisPID = System.Diagnostics.Process.GetCurrentProcess().Id;
3.
foreach (System.Diagnostics.Process proc in System.Diagnostics.Process.GetProcessesByName(application))
4.
{
5.
if (proc.SessionId == ThisSession)
6.
{
7.
proc.CloseMainWindow();
8.
proc.WaitForExit(Wait);
9.
if (!proc.HasExited)
10.
{
11.
proc.Kill();
12.
}
13.
proc.Dispose();
14.
}
|
|
|
|
|
Does this mean you are happy with the "SessionId" property?
|
|
|
|
|
it does what i need
namely doesnt kill all the winword.exe's but just he on of the user who is running my prgram
my other thing was to find out if winword.exe is respoinding
proc.responding
and
what the current cpu load is ( im still not sure how to do that)
|
|
|
|
|
Hello,
crash893 wrote: what the current cpu load is ( im still not sure how to do that)
If you whant it for overall system you could use System.Diagnostics.PerformanceCounter like this:
System.Diagnostics.PerformanceCounter cpuCounter = new System.Diagnostics.PerformanceCounter();
cpuCounter.CategoryName = "Processor";
cpuCounter.CounterName = "% Processor Time";
cpuCounter.InstanceName = "_Total";
string actusage =cpuCounter.NextValue()+"%";
If you need it for a special process look at this article: http://www.codeproject.com/csharp/processescpuusage.asp[^]
Hope it helps!
All the best,
Martin
|
|
|
|
|
that kinda of works
ill post code once i get it working spesificly
|
|
|
|
|
This may sound a like a silly question, but wouldn't it make sense if one was not allowed to kill a process programaticaly?
I mean for security and also "moral" reasons. If we a are to compare software process with human individual, that would mean murder.
|
|
|
|
|
blackjack2150 wrote: This may sound a like a silly question, but wouldn't it make sense if one was not allowed to kill a process programaticaly?
I mean for security and also "moral" reasons. If we a are to compare software process with human individual, that would mean murder.
Interesting!?
But I hope people never go that far, treating programs same as humans.
I think we should start with animals first!
|
|
|
|
|
i think we have a few more things to worry about before this conversation can be taken seriously
like killing actually people and animals
|
|
|
|
|
|
i miss spoke
i think there is more to worry about before i take blackjack2150 post seriously
|
|
|
|
|
My appliction uses Microsoft's Indexing Service, i need to ensure that when my software installs it ensures that either the service is already installed or it installs the indexing service.
Thank you!
"Mess with the Best, Die like the rest"
|
|
|
|
|
Hello,
I have a simple question. Suppose you have a class X. Now you have a Class Y, which derives from Class X. Now in Class Y can I create a member which is a object of type X, let the object name be ob.
Now Suppose Class X has a public member int a, would this be a valid statement?
[Object of type Y].ob.a = 10
Thanks
|
|
|
|
|
Ummmm, yeah? But it sounds like a poor design.
|
|
|
|
|
|
I am using a datagrid in ASP.NET. I have column setup with LinkButtons to change that row into a edit row. How do I find what row the LinkButton is in to set the edit row property?
Thanks in advance.
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
|
|
|
|
|
If you have used a command field in the gv you should have no problem.
First the gv needs to have the DataKeyNames property set to the Field that has the ID for that table.
Then you should have a method that looks like
protected void gvTrouble_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int QuestionChoiceID = (int)gvTrouble.DataKeys[e.RowIndex].Value;
DeleteRecordByID(QuestionChoiceID);
}
the e.RowIndex tells you what row your in , and that in turn can give you the id
gvTrouble.DataKeys[e.RowIndex].Value
cast or convert that into an int and use it as the id field for a deleteion
private void DeleteRecordByID(int QuestionChoiceID)
{
string quizDelete;
quizDelete = @" Delete Questions where QuestionID = " + QuestionChoiceID + " ";
// be sure to rebind the data after you drop a row.
}
PunchcardRay
|
|
|
|
|
I have an instance of the class mentionned in the subject. When I set a property using the SetPropertyValue and re-read the object from WMI, it has its old value.
-----
Formerly MP(2)
If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
|
|
|
|
|
Which WMI class are you using? What does the code you're using look like?
|
|
|
|
|
I get a ManagementBaseObject instance using ManagementObjectSearcher instance. I can see that the correct instance is returned, but the SetPropertyValue call is ineffective. Anything else I need to do after that?
-----
Formerly MP(2)
If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
|
|
|
|
|
Le Centriste wrote: Anything else I need to do after that?
Nope.
Once again, which WMI class are you retrieving and what does the code look like?
|
|
|
|
|
Sorry, I didn't catch the "WMI classes" thing, I thought ".NET classes".
The class I am playing with is a custom class. I have no problem publishing, raising events, searching on property values, and so on. The only problem is when I am trying to modify a property.
I have 2 WMI classes, one to represent an object, and another one that is an event, to warn that a new object arrived.
-----
Formerly MP(2)
If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
|
|
|
|
|
How many time do I have to ask before you'll post the code?
|
|
|
|
|
ManagementBaseObject myObj = searcher.Get("MyId = \"someId\"");
emailObj.SetPropertyValue("MyProperty", false);
The searcher call works, the SetPropertyValue one does not.
I cannot post the complete code as it is somewhat complicated because the searcher is used in many places so it is created somewhere else. This goes for the ManagementScope object also.
-----
Formerly MP(2)
If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
|
|
|
|