I'm a new user to InstallShield. I'd like to start with a simple script that checks to see if a required utility has been previously installed on a computer prior to doing a new install. If the required utility is not already on the computer then I simply want to display a message box to the user informing them to install the required utility after the new install.
What would such a script look like and where would I place it in the code?
Is there a better way to do this?
Thanks.
This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
First time user - Simple InstallScript question
Started by
GT1025
, May 08 2003 00:58
6 replies to this topic
Posted 08 May 2003 - 15:04
Welcome to InstallShield.
I'd suggest using the InstallShield wizard to make a new project, and then add the code to the OnBegin function.
How did you plan on checking for this utility? Through the presence of a file, a registry entry, or both?
I'd suggest using the InstallShield wizard to make a new project, and then add the code to the OnBegin function.
How did you plan on checking for this utility? Through the presence of a file, a registry entry, or both?
Posted 08 May 2003 - 22:08
Yes, welcome to InstallShield.
Tacobell and Stefan are the local experts on InstallShield, which makes the following a bit hard to say.
I might disagree with Tacobell just a bit on the location of the code. OnBegin() is run every time the script is run, including maintenance and/or uninstall runs. It probably wouldn't hurt to do it in OnBegin(), but you really only need to check to see if the utility is present before the first time you install on a system. Therefore I would put a call to a function (as opposed to just placing the code) in OnFirstUIBefore(), which is only run the first time the setup is run.
Tacobell is right about wanting to know how you're going to check to see if the utility is installed. I usually use a registry check, which I'll show you first. You'll need to find the correct registry key the utility installs. Try looking under HKEY_LOCAL_MACHINE. Then Software, The name of the company who made the utility, then the product name. I'll give an example of how I look for SQL 8 from Microsoft:
I find checking for files a bit more difficult dur to pathing problems and possible name changes for the files. However, IS gives you a few variables that will help you with the pathing concern. For example, many utilities will place exe's in the WINNT or System32 folders. Most people have installed their OS on the C drive, but there's no guarentee. IN such a case I use the variable IS provides. Let's say I knew the utility placed the file "foobar.exe" in the Windows System folder which is normally located at "c:Winnt/system32"; however, other people may use a differnt drive and other OS's may use a different folder. See below for the code
WINSYSDIR is a system variable and will always lead you to the correct folder for any Microsoft OS (maybe for other OS's - I'm not sure) Windows System folder.
Now if wnated to be really slick, you could always install the utility yourself if it's not there. But that would be a completely different post
Let us know if you need more help.
Tacobell and Stefan are the local experts on InstallShield, which makes the following a bit hard to say.
I might disagree with Tacobell just a bit on the location of the code. OnBegin() is run every time the script is run, including maintenance and/or uninstall runs. It probably wouldn't hurt to do it in OnBegin(), but you really only need to check to see if the utility is present before the first time you install on a system. Therefore I would put a call to a function (as opposed to just placing the code) in OnFirstUIBefore(), which is only run the first time the setup is run.
Tacobell is right about wanting to know how you're going to check to see if the utility is installed. I usually use a registry check, which I'll show you first. You'll need to find the correct registry key the utility installs. Try looking under HKEY_LOCAL_MACHINE. Then Software, The name of the company who made the utility, then the product name. I'll give an example of how I look for SQL 8 from Microsoft:
CODE |
// First I set a string to the registry key I'm looking for sSQLServer8 = "SOFTWARE\\Microsoft\\Microsoft SQL Server"; // Then I make sure it is looking in the correct root of the registry // This is very important. You don't have to do it every time you // different key, but I reuse this command any time I have switched // functions RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); // Next check for the presence of the key if (RegDBKeyExist(sSQLServer8) = 1) then // Warn your user to install the utility MessageBox("Please install SQL 8", INFORMATION); // Or you could ABort the install as well, in that case // You could use the following 2 lines //MessageBox("SQL 8 not installed, aborting",SEVERE); //abort; endif; |
I find checking for files a bit more difficult dur to pathing problems and possible name changes for the files. However, IS gives you a few variables that will help you with the pathing concern. For example, many utilities will place exe's in the WINNT or System32 folders. Most people have installed their OS on the C drive, but there's no guarentee. IN such a case I use the variable IS provides. Let's say I knew the utility placed the file "foobar.exe" in the Windows System folder which is normally located at "c:Winnt/system32"; however, other people may use a differnt drive and other OS's may use a different folder. See below for the code
CODE |
if (Is(FILE_EXISTS, WINSYSDIR^"foobar.exe"))=FALSE then // Warn your user to install the utility MessageBox("Please install SQL 8", INFORMATION); // Or you could ABort the install as well, in that case // You could use the following 2 lines //MessageBox("SQL 8 not installed, aborting",SEVERE); //abort; endif; |
WINSYSDIR is a system variable and will always lead you to the correct folder for any Microsoft OS (maybe for other OS's - I'm not sure) Windows System folder.
Now if wnated to be really slick, you could always install the utility yourself if it's not there. But that would be a completely different post
Let us know if you need more help.
There is great chaos under heaven, and the situation is excellent. (Mao Tse Tung)
Posted 09 May 2003 - 03:42
Disagree with Taco?!?!?!?! No!!! Actually that's okay Xitch13. I suggested OnBegin because he said he wanted just a simple script and sounded like more of a learning experience than an actual setup application. However, OnFirstUIBefore would probably be a better "real world" choice and preferably as a call to a local function.
I was also in a hurry putting out fires this morning or I would have written a lot more. Thanks Xitch13 for supplying him with some more info.
I was also in a hurry putting out fires this morning or I would have written a lot more. Thanks Xitch13 for supplying him with some more info.
Edited by TacoBell00, 09 May 2003 - 15:17.
Posted 09 May 2003 - 09:31
Welcome to IS again :-)
GT1025, please check the help pages and perhaps the knowledge base for the function syntax.
Xitch13 used
to display the messagebox, but if you look into the help file (does F1 on the function name work in IS6? I still use version 5) you will find that RegDBKEyExist returns 1 if the key has been found, so it would be better to check for a return value < 0.
Many funtions in InstallScript have the same return values, 0 for success, <0 for error.
But many functions return 1 for success, so it is always helpful to check the syntax, the return values and the requirements of the function (in this case you have to set the registry key to start the search with
Just play around and try this and that yand you will quickly learn how to reach your goals.
But be careful when deleting files and/or registry keys!!!
Once I removed many keys needed for windows to run, because I forgot to check a condition properly and so I deleted the wrong keys ...
Use the debugger and check what the functions return and how they work, but better do it on a test system or have a recent system image handy
GT1025, please check the help pages and perhaps the knowledge base for the function syntax.
Xitch13 used
CODE |
if (RegDBKeyExist(sSQLServer8) = 1) then |
Many funtions in InstallScript have the same return values, 0 for success, <0 for error.
But many functions return 1 for success, so it is always helpful to check the syntax, the return values and the requirements of the function (in this case you have to set the registry key to start the search with
CODE |
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); |
Just play around and try this and that yand you will quickly learn how to reach your goals.
But be careful when deleting files and/or registry keys!!!
Once I removed many keys needed for windows to run, because I forgot to check a condition properly and so I deleted the wrong keys ...
Use the debugger and check what the functions return and how they work, but better do it on a test system or have a recent system image handy
Gruß / regards
Thomas
Thomas
Posted 09 May 2003 - 14:22
Hope I don't add to much confusion, but: OnFirstUIBefore is NOT a goodplace for this check. The UI functions may be skipped in a OneClickInstall.
OnBegin would be better if you condition the check on the value of the MAINTENANCE system variable.
The CORRECT place however (I think) would be OnAppSearch.
OnBegin would be better if you condition the check on the value of the MAINTENANCE system variable.
The CORRECT place however (I think) would be OnAppSearch.
Stefan Krüger
InstallSite.org twitter facebook
Posted 09 May 2003 - 15:22
Hmm, interesting point Stefan. I've never done a OneClickInstall.
I also considered suggesting he conditionalize it based on MAINTENANCE in order to keep it in OnBegin because that's "basically" what I do with all my pre-install checks. Not exactly though since I don't use the event model much less MAINTENANCE mode.
I also considered suggesting he conditionalize it based on MAINTENANCE in order to keep it in OnBegin because that's "basically" what I do with all my pre-install checks. Not exactly though since I don't use the event model much less MAINTENANCE mode.