Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 2 of 2
  1. #1

    Terminate Process Sample

    I need to terminate a process prior to installation. I found result = System.TerminateProcess(); which also need result = System.EnumerateProcesses(); but the documentation on using them is not sufficient. For example, EnumerateProcesses returns a table but I can not figure out how to iterate it and find the ProcessID of the Executable I am looking for.

    Has anyone used those commands in a script and if so, could you share some sample code?

  2. #2
    Join Date
    May 2009
    Posts
    336
    Code:
    -- With this function you can end (terminate) a process easily by just typing the name of the process in the function.
    
    -- The function
    function System.EndProcess(strProcess)
    	strProcess = String.Lower(strProcess);
    	tblProcesses = System.EnumerateProcesses();
    	for i, strPath in pairs(tblProcesses) do
    	    local strFile = String.SplitPath(strPath);
    	    if (String.Lower(strFile.Filename..strFile.Extension)) == strProcess then
    	        System.TerminateProcess(i);
    	    end
    	end
    end
    
    -- An example
    System.EndProcess("itunes.exe")

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts