--在全局函数中增加 适用用Setup Factory 9
function FindAndCloseProcessByName(strName)
local tblProcesses = Window.EnumerateProcesses(false);
local bProcessFound = false;
local nProcessHandle = nil;
if Table.Count(tblProcesses) > 0 then
local strProcessName;
local nHandle;
for nHandle,strProcessName in pairs(tblProcesses) do
if(String.Find(strProcessName,strName,1,false) ~= -1)then
nProcessHandle = nHandle;
bProcessFound = true;
end
end
end
if(bProcessFound and nProcessHandle)then
Window.Close(nProcessHandle,CLOSEWND_TERMINATE);
end
end
--调用
FindAndCloseProcessByName("DMS_Client.exe");
FindAndCloseProcessByName("DMSAutoUpdate.exe");
--或者直接调用
strName = "Lx_Update.exe";
tblProcesses = Window.EnumerateProcesses(false);
bProcessFound = false;
nProcessHandle = nil;
if(tblProcesses)then
for nHandle, strProcessName in pairs(tblProcesses) do
if(String.Find(strProcessName,strName,1,false) ~= -1)then
nProcessHandle = nHandle;
bProcessFound = true;
end
end
end
if(bProcessFound and nProcessHandle)then
Window.Close(nProcessHandle,CLOSEWND_TERMINATE);
end