PDA

View Full Version : Hanging on while loop



pjhiggins
03-08-2004, 11:44 AM
Once again I come to the well....

I'm Installing an app, Acrobat Reader 5.1 in this case, using the Adobe blind copy configuration file for a semi-silent installation.

The normal wait for return option on the File.Run command isn't helping me because Acrobat returns a finished status way too early.
I'm trying to create a loop that will wait for the app to be installed before continuing.

Here is what I'm trying.



Acrobat_Installed = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\\Adobe\\Acrobat Reader");

<some stuff to extract the app archive to a temporary folder on C:>

File.Run("C:\\acrotemp\\Setup.exe", "", "", SW_SHOWNORMAL, true);

repeat Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\\Adobe\\Acrobat Reader") until Acrobat_Installed;

<some stuff to clean up the temporary folder>


My app installs ok but my AMS menu hangs.

Am I barking up the wrong tree with this loop or am I just a touch off on something?

Thanks!

-pjh

Stefan_M
03-08-2004, 03:20 PM
Try

--preset the condition
Acrobat_Installed=false;
repeat
--wait a little bit
Application.Sleep(3);
--check the registry key
Acrobat_Installed = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\\Adobe\\Acrobat Reader");

until (Acrobat_Installed);

problem:
this loop will never stop if the Acrobat installation fails.

CWRIGHT
03-08-2004, 03:22 PM
Hi pjh,

No loop is needed - the installshield SMS command-line parameter will resolve this for you. It stops the setup.exe sending a return until the app is fully installed. Try:

File.Run("C:\\acrotemp\\Setup.exe", "/SMS", "", SW_SHOWNORMAL, true);

For info, this only works with installshield setup's which don't use Microsoft Installer technology (such as Reader 5.1). With MSI (Reader 6+) you can use /W (for wait).

Hope that helps.

CW

Worm
03-08-2004, 03:27 PM
Another thought would be to use Window.EnumerateTitles(true) in a loop and watch for when the Installer's Window Title is no longer present.

pjhiggins
03-08-2004, 03:40 PM
Thanks to both of you.

I tried both suggestions and both work for me.

For this project I'll go with the /SMS option due to some additional subtle timing issues but I will keep notes of the registry monitor for the future.
Not every problem will be solved by a 3rd party installer command line switch :-)

Thanks again!

-pjh

pjhiggins
03-08-2004, 03:48 PM
Also a good idea Worm.

In this particular case though I am using the InstallShield blind copy .ini file to eliminate all installation dialog windows with the possible exception of some error messages that would have been blocked by the blind copy silent install option and unanswerable by an .iss response file.

Of the half a dozen apps I'm installing for this project, Acrobat and the InstallShield installer have kicked my butt nicely.
So many options that you almost have to out smart it to make it act the way you want :-)

-pjh

Worm
03-08-2004, 04:00 PM
You might try it anyway. Even though you don't see a window, it doesn't mean there isn't one there.

Edit: never mind, I see you have your solution :oops