Announcement

Collapse
No announcement yet.

did the trueupdate can overwrite a file

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

  • did the trueupdate can overwrite a file

    Hi Mark

    My question is can I overwrite a file with the true update if the application is open, modifying the .exe file of that app

    best reggard

    pedro arzac

  • #2
    The best thing to do is to detect if the program is running ahead of time and tell the user to shut it down before continuing. Something like this:

    Code:
    --[[	
    **********************************************************************************
    Function:	EnsureProgramIsClosed
    Purpose:	To ensure that a named program is shut down.				
    	enArguments:	(string) FileName - The name of the process. For example, "MyProgram.exe"
    			(string) ProgramName - The user-friendly name of the program for the
    					 message.  For example, "My Program".
    Returns:	(boolean) true if the program was shut down successfully or false if not
    **********************************************************************************
    --]]
    function EnsureProgramIsClosed(FileName,ProgramName)
    	local bKeepTrying = true;
    	local bReturn = true;
    	while g_IsProcessRunning(ProgramName) and bKeepTrying do
    			local Title = "Close Software";
    			local Message = "Please close the following program:";
    			Message = Message.."\r\n\r\n"..ProgramName;
    			local DlgResult = Dialog.Message(Title,Message,MB_RETRYCANCEL,MB_ICONEXCLAMATION);
    			if DlgResult == IDCANCEL then
    				bReturn = false;
    				bKeepTrying = false;
    			end
    	end
    	
    	return bReturn;
    end
    
    EnsureProgramIsClosed("My Software","MySoftware.exe");

    Comment


    • #3
      The code that you game me is sending me a mistake I put it in the server side, the error is in the these part

      while g_IsProcessRunning(ProgramName) and bKeepTrying do it said that programName is empty I put it like these

      EnsureProgramIsClosed("My Software","MySoftware.exe");

      please help me

      Comment


      • #4
        Hi Perdo,

        Here is the missing function that you need:

        Code:
        --[[	
        **********************************************************************************
        Function:	g_IsProcessRunning
        Purpose:	To determine if a named process is running.
        Arguments:	(string) FileName - The name of the process. For example, "MyProgram.exe"
        Returns:	(boolean) true if the program is running or false if not
        **********************************************************************************
        --]]
        function g_IsProcessRunning(FileName)
        	local tblProcesses = Window.EnumerateProcesses();
        	local bProcessFound = false;
        	if(tblProcesses)then
        		local strProcessName;
        		local nHandle;
        		for nHandle, strProcessName in tblProcesses do
        			if(String.Find(strProcessName,FileName,1,false) ~= -1)then
        				bProcessFound = true;
        			end
        		end
        	end
        	
        	return bProcessFound;
        end
        Put that code above the code that Brett posted and all should be well.
        MSI Factory The Next Generation Intelligent Setup Builder

        Comment


        • #5
          Seems like there is a bug in the functions that were posted here (and are included with the distribution).

          In g_EnsureProgramIsClosed(), you make the following call:
          while g_IsProcessRunning(ProgramName) and bKeepTrying do

          I'm pretty sure this is supposed to be:
          while g_IsProcessRunning(FileName) and bKeepTrying do

          Comment


          • #6
            Just a follow up on my previous post.

            The code that is in the release is from Visual Patch v2.0.

            Seems like there is another bug in g_IsProcessRunning().

            The test for a process running is:
            if(String.Find(strProcessName,FileName,1,false) ~= -1)then

            I think this should really be:
            if(String.CompareNoCase(strProcessName,FileName) == 0)then

            e.g.
            Instead of running my app directly, I run my updater and then it calls my apps once it is complete.
            The problem came up because my updater is called "updater.app.exe" and my app is called "app.exe".
            When I run a patch, String.Find() is called with "app.exe" and "updater.app.exe". This in turn complains that my app is running when in fact it is not.

            Comment


            • #7
              Was this ever verified as a bug? I just noticed that the same problem exists in VP3.

              Thanks.

              Comment

              Working...
              X