View Full Version : I need to save all currently running processes in a table via "NameFile.Extension"
123456789
04-29-2008, 10:23 AM
I need to save all currently running processes in a table via "NameFile.Extension"
i need a result look like:
table={"autorun.exe", "services.exe","winlogon.exe", "smss.exe", "spoolsv.exe","svchost.exe", "csrss.exe", "system idle process", "system", "svchost.exe", "alg.exe", "ctfmon.exe", "sqlwriter.exe", "sqlservr.exe"};
I see contents of above table in Task Manager .
AMS help not help me in this case.
ShadowUK
04-29-2008, 10:24 AM
table = System.EnumerateProcesses()
123456789
04-29-2008, 11:23 AM
Hi ShadowUK
It is not a real table!
It's a table whit special contents.
I need to get content look like:table={"autorun.exe", "services.exe","winlogon.exe"};
"NameFile.Extension"
please run it and see result:
processes = System.EnumerateProcesses();
numLoopCount = 1;
repeat
result = Dialog.Message("msg", processes, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
numLoopCount = numLoopCount + 1;
if (processes[numLoopCount] == nil) then Application.ExitScript(); end
until numLoopCount==50;
ShadowUK
04-29-2008, 12:28 PM
Hi ShadowUK
It is not a real table!
It's a table whit special contents.
I need to get content look like:table={"autorun.exe", "services.exe","winlogon.exe"};
"NameFile.Extension"
please run it and see result:
processes = System.EnumerateProcesses();
numLoopCount = 1;
repeat
result = Dialog.Message("msg", processes, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
numLoopCount = numLoopCount + 1;
if (processes[numLoopCount] == nil) then Application.ExitScript(); end
until numLoopCount==50;
What do you mean? It is a real table, You're theory of tables is a lot different to the real lua tables, anyway. I fixed up your code, Seriously though, You're trying to Dialog.Message a table, The second argument allows strings, Not tables!
local NewTable = {};
for id, path in System.EnumerateProcesses() do
NewTable[Table.Count(NewTable) + 1] = String.SplitPath(path).Filename
end
local StringedTable = Table.Concat(NewTable, "\r\n", 1, -1);
Dialog.Message("Processes Running:", StringedTable);
TimeSurfer
04-29-2008, 01:15 PM
Here's a couple of function's I made that do what your wanting.
Function 1 - Populates process name and path to a Tree
function PopulateProc2Tree()
processes = System.EnumerateProcesses();
for i,p in processes do
proc = String.SplitPath(p);
procNodeProp = {}
procNodeProp.Text = String.Lower(proc.Filename..proc.Extension)
procNodeProp.Data = p
Tree.InsertNode("Tree1", "1", procNodeProp);
end
end
Function 2 - Creates a table of all process name's and converts them to a string.
function proc2table()
processes = System.EnumerateProcesses();
ind = 0
tblCproc = {}
for i,p in processes do
proc = String.SplitPath(p);
procnam = String.Lower(proc.Filename..proc.Extension);
ind = ind + 1
Table.Insert(tblCproc, ind, procnam);
end
proclist = Table.Concat(tblCproc, "\r\n", 1, TABLE_ALL);
Dialog.Message("Notice", proclist, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end
If you use function2 and you really want the table returned delimited by ; then change the following line....
proclist = Table.Concat(tblCproc, "\r\n", 1, TABLE_ALL);
to
proclist = Table.Concat(tblCproc, ";", 1, TABLE_ALL);
-Personal Note-
Everything I have done in the above functions could have been easily found out via the help file. Read it carefully and it should explain itself. [Not givin ya a hard time but this one should have been relatively easy for you, as everything is outlined in the helpfile.]
123456789
04-30-2008, 12:52 AM
shadowuk, U are a great man.
Thanks a lot for your Kindness to me.
Codes is very usefull for i and other user.
TimeSurfer
I enjoy from your ASCENDENCY Intellect.
I hopes be you Prosperous in life and jobs always.
Thanks for all helps.
123456789
----------
TimeSurfer
04-30-2008, 01:56 AM
;)lol just my wymsical humor lol and no problem m8 happy to help
Powered by vBulletin™ Version 4.0.6 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.