No announcement yet.

Executing / Deleting EXE file

  • Filter
  • Time
  • Show
Clear All
new posts

  • Executing / Deleting EXE file

    I need to have a .exe file execute after all of the files in the msi have been installed, and then I need to delete that .exe file after it has finished executing. How would I do that?

    I have tried using a "Run Executable" custom action for the .exe file (ID = ExecuteFile) that is scheduled as "Deferred - Commit" and "Async wait", with the timing as "After- PublishComponents".

    Then I created a Run LuaScript" custom action (ID = DeleteFile) that simply deletes the file in the luascript, which is scheduled as "Immediate" and "Check", with the timing as "After - ExecuteFile".

    But the DeleteFile action always happens long before the ExecuteFile action. I would have thought that with the ExecuteFile action set as "Async wait" that the DeleteFile action would not happen until the ExecuteFile thread was completed.

  • #2
    Where are you deploying the file, under ProgramFilesFolder or somewhere else where elevation is required to delete the file? In this case, you cannot use an Immediate LuaScript action, because it works with impersonation - running in user context, not as admin. For this to work, you will need the LuaScript in deferred mode, which allows you to run the script with elevation.

    In this situation, I would do both actions in LuaScript: Time it as "Before InstallFinalize", then run the app with File.Run(), wait for it to finish, then delete the file. Make sure that you set a condition to run the script only if the product is not installed, so MSI will not attempt to perform the action in repair mode or during uninstall.

    This sounds like a case where a bootstrapper could be used. You could add the file to the bootstrapper's resources, so it is not part of the MSI. You could also run and delete the file, once the MSI was processed.



    • #3
      Hey thanks Ulrich. I like the idea of running the file in LuaScript. I will do it that way now. Thanks.