Archive: Autorun pb: preventing install when already installed


Autorun pb: preventing install when already installed
Hi,

I'm making an installer (setup.exe on a CD) for a commercial game.

Currently, setup.exe is launched each time the CD is inserted (using autorun.inf).

This is quite annoying for the player when he has already installed the game, as he needs to insert the CD to play the game.

I would like to prevent this. I have 2 ideas:

1/ Use an intermediate executable (let's call it check.exe)
Have autorun.inf call check.exe instead of setup.exe
check.exe checks if the game is installed (by looking at the registry) and decides whether or not to launch setup.exe.

Questions:
Has anybody done this?
Are there freeware tools to make this quickly? I don't particularly want to reinvent the wheel...

2/ Add a check (registry) in .onInit and cancel installation when the game is already installed.

Questions:
Has anybody done this?

Is this really a good idea? Currently, my installer takes about one minute to launch before .onInit can do anything ("Please wait while setup is loading...). Of course, i can disable that with "CRCCheck off", but then i'm making my installer less secure...

Thanks for your valuable help.

eboots


It's much easier than that really.

1. Write some registry key to say that the game is installed in your install Section.
2. Get autorun.inf to pass an extra param to setup.exe, lets say /AUTORUN (in case user decides to run setup.exe to reinstall game).

Combine the two, and if both are set you just call Abort.

E.g.

Function .onInit
Call GetParameters
Pop $R0
ReadRegStr $R1 "HKCU" "Software\Company\Game" "Installed"
StrCmp $R0 "/AUTORUN" 0 End
StrCmp $R1 "1" End
Abort
End:
FunctionEnd


GetParameters is in the NSIS Manual under Useful Scripts.

Edit: As for CRCCheck, if your setup file is on a CD/DVD then it'll be less likely to be corrupt right? I think CRCCheck is only really necessary for packages to be downloaded from the Internet.

-Stu

If you want to get into the nitty-gritty, you could include another NSIS executable on your CD called, say, MD5Check.exe which will:

1. Be executed by setup.exe in .onInit (setup.exe will immediately call Abort)
2. The executable will check the MD5 checksum of the setup file (using the MD5 plugin) by comparing it to a predefined checksum (defined on compile time).
3. If they do not agree, give the user an error message (or something?)
4. Otherwise, run setup.exe with another parameter, say /MD5OK and Abort itself too (all this should be done in .onInit)
5. Finally, setup.exe will detect the /MD5OK param with GetParameters and continue with installation.

Sounds a bit nasty though, plus the user getting that error message which would probably have to say "Your CD is damaged!" would not be a good idea ;)

-Stu


Thanks!

I did go through the pain of developing a launcher exe but then I read your replies and decided to follow your advice.

It always sounds better when somebody else says it ;-)

When I have time, i'll try to post my little launcher in case it's useful to someone.

eboots