Saved Bookmarks
| 1. |
Solve : what is tasklist command "PID no."? |
|
Answer» In tasklist command, So the question is Can i make use of PID no's to find out that which one is older or newer process?NO. Quote & Can i correlate that which PID no. is associated with which session?don't understand to have better programming control over the things you do, try using vbscript.(natively) this vbscript terminates the latest (newest process) of the same type Code: [Select]Set objFS=CreateObject("Scripting.FileSystemObject") Set objArgs = WScript.Arguments strProcess = objArgs(0) strComputer = "." Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where Name = '"&strProcess&"'") t=0 For Each objProcess in colProcessList s = Replace( objProcess.CreationDate ,".","") s = Replace( objProcess.CreationDate ,"+","") If s > t Then t=s strLatestPid = objProcess.ProcessID End If Next WScript.Echo "latest: " & t , strLatestPid Set colProcess = objWMIService.ExecQuery("Select * from Win32_Process where ProcessId =" & strLatestPid) For Each objProcess in colProcess objProcess.Terminate() Next to use it on the command line type Code: [Select]c:\test> cscript //nologo killbill.vbs "notepad.exe" i leave it to you to find the oldest if you are interested.Quote from: Yogesh123 on Today at 04:09:14 AM "So the question is Can I make use of PID no's to find out that which one is older or newer process?" Quote from: ghostdog74 on December 11, 2009, 04:37:59 AM NO, you cannot make use of PID no's to find out that which one is older or newer process?" How does Casper know: "You cannot make use of PID no's to find out that which one is older or newer process?" p.s. The smaller the PID number, The older the process? Quote p.s. The smaller the PID number, The older the process? You might think that, but you would be wrong. A simple script that selects all the instances of the svchost along with the PID and the CREATION date will show PID numbers are assigned rather haphazardly. Quote ========================================== You'll notice that the last instance of svchost which was assigned the lowest PID. I wouldn't count on a correlation between the PID and the age of the process. Better to use the creation date and calculate the age. Quote from: billrich on December 11, 2009, 11:24:51 AM How does Casper know: "You cannot make use of PID no's to find out that which one is older or newer process?" Why does billrich the tosser post RUBBISH?Quote from: billrich on Today at 11:24:51 AM How does Casper know: "You cannot make use of PID No's to find out that which one is older or newer process?" Quote from Billrich: "p.s. The smaller the PID number, The older the process?" Quote from: Sidewinder on December 11, 2009, 12:15:55 PM You might think that, but you would be wrong. A simple script that selects all the instances of the svchost along with the PID and the creation date will show PID numbers are assigned rather haphazardly. Sidewinder: Thanks for your post and explanation of PIDs. Some of the negative posters are confused and vindictive. Quote from: billrich on December 11, 2009, 11:24:51 AM How does Casper know: "You cannot make use of PID no's to find out that which one is older or newer process?"I know it can't because i have been doing sysadmin + IT security for years and i know how PIDs behave. That's why i say NO. if you do not know or are unconvinced, you can try out for yourself , couldn't you? hahaha "smaller Pids are older" hilarious assumption, especially considering the ProcessID and Process Handle are essentially memory POINTERS, and therefore subject to memory allocation rules, which are pretty haphazard in themselves. You cannot, for example, know at any one point where in memory a structure will be allocated any more then you can predict the ordering of the allocations based on the time they are performed. Especially on account of the fact that memory is allocated and reallocated quite often; to say that "the lower Pids are older" is like SAYING that the files at the beginning of a disk are the oldest ones. |
|