Here's an example script. It looks really long, but it's actually only 13 lines long. I've just spaced the commands, and commented the crud out of it, lol.
Copy it, paste into the autoit editor, save it as "script.au3" (or whatever) and modify it to suit your program/game.
When it's pasted into the autoit editor, all the commands will automatically get color-coded to make it easier to read.
You can download the free AutoIt editor/compiler here: http://www.autoitscript.com/site/autoit/downloads/ (it's the first download in the table)
The problem that I can see with this though, is that while the setup file is running, the user can go in to the temp directory, copy the extracted setup file and paste it elsewhere. Then if they want to run the setup file later WITHOUT doing any of the checks, they just need to run the one that they copied out or the temp directory. A lot of Popcap games use the above script method, and have/had this vulnerability.
;Set the temp setup file path here
$TempFile = @TempDir & "\GameSetup.exe"
;Read the game's installation path from the registry
;To read a 64-bit registry entry, replace HKLM with HKLM64 (or HKCU with HKCU64, etc.)
$InstallPath = RegRead("HKLM\SOFTWARE\My Company\My Game", "InstallPath")
If Not FileExists($InstallPath & "\Game.exe") Then ;You can also replace this variable with a static path, such as @ProgramFilesDir & "\My Game\Game.exe"
;If the file doesn't exist, display an error message instead of extracting/running the setup file
MsgBox(16, "Upgrade Not Available", "You don't currently have a version of the game installed." & @CRLF & "Setup will not continue") ;Note: @CRLF = newline
;If the file DOES exist, run some exe and wait for it to close...
RunWait($InstallPath & "\the exe you want to run before setup.exe")
;...then display a progress bar to tell the user that the installation files are being extracted...
ProgressOn("Setup", "Please Wait", "Extracting Setup Files...")
;...extract the setup file (located in the same directory as this script) into the temp path stated at the top of the script
;(This file will be compressed into the exe that this script gets compiled into, so you just need to distribute the 1 exe (this script))
FileInstall(".\Setup.exe", $TempFile, 1)
;After the file is extracted, close the progress bar
;Run the extracted setup file, and wait for it to close
;Once it's closed (finished), delete the setup file out of the temp directory
;The rest here are notes, not part of the above script.
;To get the return code of an exe, assign RunWait() to a variable. E.g.
$ReturnCode = RunWait($InstallPath & "\some.exe")
;Will run $InstallPath & "\some.exe", wait for it to finish, and then store its return code into the $ReturnCode variable.
;This is handy for if you have an exe to do license validation, etc. and have it return a certain code for valid/invalid.
;You can then do something like the following:
If $ReturnCode = 1 Then
If it's being used just to see if a file exists or not, then it will be fine, but it's not very secure if you want to use it for license validation, etc.
One way to secure the above vulnerability a little better, would be to ALSO set the option in Install Creator Pro that Yves and I mentioned in previous posts in this thread. That way, even if they copy the file out and run that instead, it STILL won't install because the certain file doesn't exist, and the installer won't continue. Don't rely of the wrapper alone.