PDA

View Full Version : Check if a program is installed before running installation



LiquidIce
09-08-2014, 07:19 AM
Hello guys,

I would like to make the installer check if a component of the installation is already installed in order to avoid having to re-install it and possibly losing program configurations that are already present. Is there a way to do this? The method I would use is check if a process is running or check if folder exists, if it does, skip the installation of that program.

Thank you!

linder
09-08-2014, 07:31 AM
Hello,

Sure, no problem. You can check if the component is already there (e.g. check for a specific file or registry entry, etc.) and then, based on the result of your check, enable/disable the Feature using the "Set Feature State..." script function. Or just put a simple IF/Then Statement around that installation part.

Friedrich

LiquidIce
09-08-2014, 07:35 AM
Hello Friedrich,

I want to do this via the script editor, I click on "Check In-use File" and it asks me for a Variable and a Path name. I understand that the variable must be one I make up so that I can use it in the future for an if/then? And what goes in Path name? Where the file is located?

Thank you.

Alejandro.

linder
09-08-2014, 07:46 AM
Alejandro,

Only you (the developer) know where the file is located ;) But why use "Check In-Use File...". I thought your intention was to see if a file does exist? The Check In-use File function lets you determine whether a particular file on the destination computer is in use or not! Not what you are trying do do.

As I understand it, you need "If File/Folder exists..." or "Detect Previous Version..." etc.

Friedrich

linder
09-08-2014, 07:50 AM
Similar to this...

Friedrich

LiquidIce
09-08-2014, 08:52 AM
Hello Friedrich,

This is what my code looks like:

http://cl.ly/image/421F0j3E3s06/Screen%20Shot%202014-09-08%20at%2016.11.03.png

I don't think that this will work because the Feat says that Always Install, but it always installs it. I looked over the Features but I couldn't find where to disable this Always Instal...

Regards,

Alejandro

linder
09-08-2014, 09:05 AM
Alejandro,

Your code is not correct.

1. %%PROGRAMFILES%% is not correct here. You have to use the runtime variable (e.g. %PROGRAMFILESDIR%).

2. You check if "googledriesync.exe" is in-use (means: running/active/locked). Your %ISINSTALLED% variable value is "1" if the file is in-use, it is "0" if the file is not in-use and "-1" if the file could not be found.

3. Your If Statement in Line 72 is incorrect (from the technical point-of-view) and does not work.

BTW, by default, a project has a (non-removable) single feature called "Always Install". All files in this feature are automatically installed regardless of the setup type the user selects. Of course, if you put an If Statement around this line and the Statement resolves to FALSE then it will NOT be installed. But your If Statement in Line 72 is not correct so it does not do what you want here.

Friedrich

LiquidIce
09-08-2014, 09:22 AM
Hello Friedrich,

If I use %PROGRAMFILES% it gives me an error stating that this has not been previously defined. I updated my code to this since you told me all about the 1 - 0 or -1.

Here is the code updated:
http://cl.ly/image/0l1M0S06100W/Screen%20Shot%202014-09-08%20at%2017.19.42.png

And here is what the feature is configured to do:
http://cl.ly/image/3P2S1a0z3Q3d/Screen%20Shot%202014-09-08%20at%2017.20.22.png

I'm kind of confused because my "if this then that" is set to: if file googledrivesync.exe is not found, run the installation, else, carry on.

Thanks,

Alejandro

linder
09-08-2014, 09:38 AM
Alejandro,

Unfortunately, your code is still incorrect. %%PROGRAMFILES(x86)%% is wrong. You should use something like this: %PROGRAMFILESDIR% And there is a huge difference between "/" and "\" in Windows. So "/Google/Drive/googledrivesync.exe" is an invalid path specification in Windows.

It should look like the attached one (quick and dirty demo).

Friedrich

LiquidIce
09-08-2014, 09:55 AM
Hey Friedrich,

I found that this was getting too complicated and decided to play it out a little different with a simple if-else. If %PROGRAMFILESDIR%\GOOGLE\DRIVE\GOOGLEDRIVESYNC.EXE File or Folder Exists then do nothing, else Install File C:\....googledrivesync.exe Feat Always Install.
But this doesn't work...

Here is an image:
http://cl.ly/image/1P1x1V2K141S/Screen%20Shot%202014-09-08%20at%2017.54.26.png

I'm going to email/pm you the project so that you can try it out.

Regards,

Alejandro

linder
09-09-2014, 12:53 AM
Alejandro,

If it does not work then you are doing something wrong. Not exactly sure what you are trying to do, but why don't you simply use the NEVER Replacement Condition? Then it will only install the file if it does not already exist.

Or just send your project and we can tell you what causes it.

Friedrich

LiquidIce
09-09-2014, 01:20 AM
Hello Friedrich,

I tried sending you a private message through the forums but it says that you do not allow recieving them, how can i send it to you?

Regards,

Alejandro

linder
09-09-2014, 01:24 AM
Hi Alejandro,

if you are interested, you can send the .sb8 file to support [at] lindersoft [dot] com and we'll review the project for you.

Friedrich

LiquidIce
09-09-2014, 03:41 AM
Hello Friedrich,

I sent the email to the account you indicated.

Thank you.

Alejandro.

linder
09-09-2014, 04:25 AM
Alejandro,

You have set the %_SB_INSTALLDIR% folder to %PROGRAMFILESDIR%\UserZoom\[PRODUCTNAME]. At runtime, this will resolve to:

C:\Program Files (x86)\UserZoom\UserZoom

But you perform the following check:

If %PROGRAMFILESDIR%\GOOGLE\DRIVE\GOOGLEDRIVESYNC.EXE File or Folder exists Then

So it will ALWAYS install your "googledrivesync.exe" because you NEVER install to:

C:\Program Files (x86)\GOOGLE\DRIVE

Instead, you install:

C:\Program Files (x86)\UserZoom\UserZoom\googledrivesync.exe

In other words, your "If Statement" is always FALSE and the "Else Statement" is executed. You have a minor folder issue here.

Does this help?

Friedrich

linder
09-09-2014, 04:37 AM
Alejandro,

I am still not sure what you are trying to accomplish, but I think you would like to do something similar to the attached?

Friedrich

LiquidIce
09-09-2014, 04:53 AM
Hello Friedrich,

What my app does is: Check if Google Drive is installed in this computer and is currently running or the file/folder exists. IF it does, then I don't want to install it. IF it doesn't, I want it to run the googledrivesync.exe which is the installer that Google gives you for Google Drive, which I will rename to InstallGDrive.exe
I don't want InstallGDrive.exe to be installed inside my application's folder, I want it to install in the default folder it has to go to(C:\ProgFiles\Google\Drive\googledrivesync.exe). googledrivesync.exe is what runs the application Google Drive, not the installer itself, I have renamed the installer to InstallGDrive.exe

linder
09-09-2014, 05:12 AM
Hi Alejandro,

Aha, okay. This is the wrong way to handle it. Your deployment strategy is simply not correct. I'll try to develop a quick-and-dirty demo for you.

Friedrich

linder
09-09-2014, 07:04 AM
Alejandro,

Okay, I have developed two different methods for you (very quick-and-dirty -- you can fine tune it with check boxes, custom messages, uninstall actions, etc.). It's just to demonstrate on how to do it. BTW, there are different methods available on how to detect an installed product. The recommended way is to check the Product GUID. I have used your .exe detection method here.

http://www.lindersoft.com/projects/GoogleDriveDemo.zip


1. Offline Installation (recommended method)

This can be used for a silent unattended installation.

https://support.google.com/a/answer/2490101?hl=en

Download the file "gsync_enterprise.msi" and copy it into the folder where the "GoogleDrive_msi.sb8" project file is located in.

https://dl.google.com/drive/gsync_enterprise.msi

Then compile and run GoogleDrive_msi.sb8.

2. Online Installation

Google does NOT support a silent unattended installation.

Download the Google Drive installer and copy your "googledrivesync.exe" into the folder where your "GoogleDrive.sb8" project file is located in.

Then compile and run GoogleDrive.sb8.


Hope this helps a bit.

Friedrich

LiquidIce
09-09-2014, 07:50 AM
Hello Friedrich,

I took your base code and modified it to my taste and it works perfectly, i'll be sure to use this methodology in the future.

Thank you very much.

Alejandro.

linder
09-09-2014, 08:03 AM
You are very welcome :)

Friedrich