Saturday, 28 August 2010

Problem: 7-Zip SFX extracted files disappearing?

I had a self-extracting archive made using 7-Zip SFX. I had many files inside the compressed file. There was one exe file, let's called it A.exe, it was the one run on extraction. In addition A.exe ran another file B.exe. The problem was that upon extraction the B.exe wasn't there! Why didn't it execute, why wasn't it there?

The reason was that my first file, A.exe was an AutoIt script. I used the Run() function to execute B.exe. This was a mistake because the 7-Zip SFX deletes the extracted files after A.exe had finished executing. This meant that B.exe wasn't there or associated files weren't there at execution time. This problem only surfaced when extracting to a SSD (Solid State Disk), maybe because the write times are slower to SSD?

The solution was to change the function to RunWait(). This function runs an external program and waits for it to finish executing before continuing. As long as your first exe (A.exe in my example) is still running, the 7-Zip SFX will not delete the temporary files - problem solved! 
Post a Comment