Announcement

Collapse
No announcement yet.

To kill running application

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • To kill running application

    I have created an installer, but it needs to check if the application is running (a .exe), and if it is runnning, then kill it before my installation starts.
    I tried the Service.Stop to do this, but it didnot serve the purpose...
    I donot know how to kill a running process in setup factory. So can anyone help me with any functionality to do this.

  • #2
    Originally posted by kk250040 View Post
    I have created an installer, but it needs to check if the application is running (a .exe), and if it is runnning, then kill it before my installation starts.
    I tried the Service.Stop to do this, but it didnot serve the purpose...
    I donot know how to kill a running process in setup factory. So can anyone help me with any functionality to do this.
    This should REALLY be in the discussion forum, not the suggestion forum.

    Look for FindAndCloseByName in the forums. There's a lengthy discussion and code examples.

    Comment


    • #3
      Hi Jassing,

      Thanks, I got few tips from all of them, I am done with this now.
      Incase soemone needs the same, I am pasting the sample code for them to try...:yes
      This code works great for me...
      ThankYou again

      Code:
      -- Check if Application is running and prompt user to shutdown the application to continue or abort if the user clicks Cancel.
      function IsProcessRunning(FileName)
      	local tblProcesses = Window.EnumerateProcesses(false);
      	local bProcessFound = false;
      	if(tblProcesses)then
      		local strProcessName;
      		local nHandle;
      		for nHandle, strProcessName in tblProcesses do
      			Debug.Print("Process name: "..strProcessName.."\r\n");
      			if(String.Find(strProcessName,FileName,1,false) ~= -1)then
      				bProcessFound = true;
      				break;
      			end
      		end
      	end
      	return bProcessFound;
      end
      
      function EnsureProgramIsClosed(FileName,ProgramName)
      
      	Debug.Print("Trying to ensure that "..FileName.." file is closed.\r\n");
      	local bKeepTrying = true;
      	local bReturn = true;
      	while IsProcessRunning(FileName) and bKeepTrying do
      		local Title = SessionVar.Expand("%WindowTitle%");
      		local Message = "The MyApplication must be shutdown in order for the Setup to continue. ShutDown the application and then click Retry to continue or Cancel to abort the Setup."
      		local DlgResult = Dialog.Message(Title, Message, MB_RETRYCANCEL, MB_ICONEXCLAMATION);
      		if DlgResult == IDCANCEL then
      			bReturn = false;
      			bKeepTrying = false;
      		end
      	end
      	
      	return bReturn;
      end
      
      if EnsureProgramIsClosed("TheApplicationsEXE.exe","My Application's Name") then
          -- continue installing
      else
      	Application.Exit(0);
      end

      Thanks,
      Kusuma

      Comment


      • #4
        Originally posted by kk250040 View Post
        Hi Jassing,

        Thanks, I got few tips from all of them, I am done with this now.
        Incase soemone needs the same, I am pasting the sample code for them to try...:yes
        This code works great for me...
        ThankYou again

        Code:
        -- Check if Application is running and prompt user to shutdown the application to continue or abort if the user clicks Cancel.
        function IsProcessRunning(FileName)
        	local tblProcesses = Window.EnumerateProcesses(false);
        	local bProcessFound = false;
        	if(tblProcesses)then
        		local strProcessName;
        		local nHandle;
        		for nHandle, strProcessName in tblProcesses do
        			Debug.Print("Process name: "..strProcessName.."\r\n");
        			if(String.Find(strProcessName,FileName,1,false) ~= -1)then
        				bProcessFound = true;
        				break;
        			end
        		end
        	end
        	return bProcessFound;
        end
        
        function EnsureProgramIsClosed(FileName,ProgramName)
        
        	Debug.Print("Trying to ensure that "..FileName.." file is closed.\r\n");
        	local bKeepTrying = true;
        	local bReturn = true;
        	while IsProcessRunning(FileName) and bKeepTrying do
        		local Title = SessionVar.Expand("%WindowTitle%");
        		local Message = "The MyApplication must be shutdown in order for the Setup to continue. ShutDown the application and then click Retry to continue or Cancel to abort the Setup."
        		local DlgResult = Dialog.Message(Title, Message, MB_RETRYCANCEL, MB_ICONEXCLAMATION);
        		if DlgResult == IDCANCEL then
        			bReturn = false;
        			bKeepTrying = false;
        		end
        	end
        	
        	return bReturn;
        end
        
        if EnsureProgramIsClosed("TheApplicationsEXE.exe","My Application's Name") then
            -- continue installing
        else
        	Application.Exit(0);
        end

        Thanks,
        Kusuma
        Why didn't the file.run() work with the "wait for return" set to true?

        Comment


        • #5
          File.Run works fine for me when the wait-for-return was set to true, but if i am not wrong the question you put was of a different thread that we both spoke of this :-)
          and me too again I posted these replies on Suggestions forum where I am supposed to put it in Discussions in this respective thread, sorry for that
          Last edited by kk250040; 03-05-2008, 11:37 AM.

          Comment

          Working...
          X
          😀
          🥰
          🤢
          😎
          😡
          👍
          👎