Solved

InstallShield - Setting The Destination Path

Posted on 2000-03-06
16
3,117 Views
Last Modified: 2013-12-03
Greetings:

I need to do a basic transfer of files.

From within the 'Components' pane, I'm assuming I need to set the 'Destination variable.  However, the destination properties (shown below) don't allow folder creation directly from the root directory such as 'C':

Windows Operating System
Program Files Folder
General Application Destination
Scrip-defined Folders

My first question is, should I use the 'Scrip-defined' option?  If so, is it necessary to define the script variable (svDir), and where is the appropriate function found?  Although it's obvious that some function takes the svDir variable, it's not obvious which function this is, or where svDir is defined such as "C:\\Reports\\"

Second question: from within the 'Media Build Wizard', the option is given to select the 'Disk Type'.  I'm assuming that at some point the installation program and files are transferred to the media disk chosen here.  Where is there an option to create each media disk?

Will increase points if needed.


0
Comment
Question by:John500
16 Comments
 
LVL 7

Expert Comment

by:ahalya
ID: 2588609
John500,

I use IS Express and am not sure how different is IS from IS Express. But for your info:


Installshield is a Window9x "certified" installation program, and therefore does default to "ProgramFilesDir\YourAppName" directory.  Mocrosoft doesn't like you to store "Program Files"  in other places and hence the limitation.

However, your user can select an alternate directory.

For your second Q, yes IS, (at least the Express version) gives you the option  to copy each of the disks.
0
 
LVL 4

Expert Comment

by:abancroft
ID: 2588727
Usually the user chooses the destination folder for the application & other folders are either relative to that (TARGETDIR) or one of the other fixed folders (windows, system, program files etc.).

If you want to copy a component to a fixed location:
1. Set the component destination to a script defined folder (e.g. <REPORT_DIR>)
2. In the script call ComponentSetTarget(MEDIA, "<REPORT_DIR>", "C:" ^ "REPORTS");
0
 
LVL 4

Expert Comment

by:abancroft
ID: 2588734
For the media question: When you build the media (using the Media Build Wizard), IS will create folder(s) under the project "Media" sub folder.

You can either copy these to the media disk manually or use the 'Send Media To' option to copy them to removeable disks.
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 86

Expert Comment

by:jkr
ID: 2588738
abancroft is right, setting

TARGETDIR="c:\\whatever";

in your script is sufficiant...
0
 
LVL 4

Expert Comment

by:abancroft
ID: 2588845
In a way:
  TARGETDIR="c:\\whatever";
will set the target folder for ALL components.

If you want a single component to be copied to a fixed folder other than the target folder, you'll need to use script defined folders.
0
 

Author Comment

by:John500
ID: 2588864
abancroft,

When you say:

If you want to copy a component to a fixed location:
1. Set the component destination to a script defined folder (e.g. <REPORT_DIR>)
2. In the script call ComponentSetTarget(MEDIA, "<REPORT_DIR>", "C:" ^ "REPORTS");

After I set the component destination to a script folder, where should I make the call to ComponentSetTarget.  Here is the way the main program looks now:

program
    Disable( BACKGROUND );

    CheckRequirements();

    SetupInstall();

    SetupScreen();

    if (ShowDialogs()<0) goto end_install;

    if (ProcessBeforeDataMove()<0) goto end_install;

    if (MoveFileData()<0) goto end_install;

    if (ProcessAfterDataMove()<0) goto end_install;

    if (SetupRegistry()<0) goto end_install;

    if (SetupFolders()<0) goto end_install;


  end_install:

    CleanUpInstall();

     // If an unrecoverable error occurred, clean up the partial installation.
     // Otherwise, exit normally.

    if (bInstallAborted) then
        abort;
    endif;

endprogram


0
 
LVL 4

Expert Comment

by:abancroft
ID: 2589345
You have to do it before you call ComponentMoveData() - I would recommend in ProcessBeforeDataMove().

0
 

Author Comment

by:John500
ID: 2592316
Adjusted points to 200
0
 

Author Comment

by:John500
ID: 2592317
abancroft,

I increased the points because now I need some help with the overall 'InstallShield' application.  In other words, even with the changes suggested above, it's not working.  It could be a number of things.  Therefore, how about verifying that I've done some things correctly.

First of all, the user will not be given the choice to choose a directory for the install.  I would like to have one component with five file groups.  It would be nice if each file group included one parent folder in the install instead of just the file.  Is there anyway to do this?

If not, the user's current directory structure contains the folder I mentioned above.  However, I was hoping to delete everything in the users current directory (including the parent directory) by over-writing them.  Any suggestions of how this (deleting) could be done?

So here is the InstallShield structure:

Component:   Program Files

File Groups: Dir_1, Dir_2, Dir_3, Dir_4, Dir_5

With the structure above I can't get the program to run right.  Here is what I've done within ProcessBeforeDataMove():

function ProcessBeforeDataMove()
    STRING svLogFile;
    NUMBER nResult;
 begin

  InstallationInfo( @COMPANY_NAME, @PRODUCT_NAME, @PRODUCT_VERSION, @PRODUCT_KEY );

  svLogFile = UNINST_LOGFILE_NAME;

  nResult = DeinstallStart( svDir, svLogFile, @UNINST_KEY, 0 );
  if (nResult < 0) then
      MessageBox( @ERROR_UNINSTSETUP, WARNING );
  endif;

  szAppPath = TARGETDIR; // TODO : if your application .exe is in a subdir of TARGETDIR then add subdir
  ComponentSetTarget(MEDIA, "<Dir_1>", "C:"^ "Folder1");
ComponentSetTarget(MEDIA, "<Dir_2>", "C:"^ "Folder2");
ComponentSetTarget(MEDIA, "<Dir_3>", "C:"^ "Folder3");
ComponentSetTarget(MEDIA, "<Dir_4>", "C:"^ "Folder4");
ComponentSetTarget(MEDIA, "<Dir_5>", "C:"^ "Folder5");


  if ((bIs32BitSetup) && (bIsShellExplorer)) then
      RegDBSetItem( REGDB_APPPATH, szAppPath );
      RegDBSetItem( REGDB_APPPATH_DEFAULT, szAppPath ^ @PRODUCT_KEY );
      RegDBSetItem( REGDB_UNINSTALL_NAME, @UNINST_DISPLAY_NAME );
  endif;

  // TODO : update any items you want to process before moving the data
  //

  return 0;
 end;

I haven't messed with the variable 'TARGETDIR' but I can see it is still affecting the results.  If I allow the user to choose the directory path, then the program works, otherwise, I'm just about certain that TARGETDIR is messing things up.  I do know that the value of TARGETDIR is causing two subdirectories to be created in the 'Program Files' folder.  In addition, the two subdirectories are being created based upon the company name and project name.  How can I keep InstallShield from creating these subdirectories?  As I mentioned, if I allow the user to choose the directory, the program works but the two subdirectories within the 'Program Files' are still created.  I still don't want the user to choose the directory path, but this should prove that TARGETDIR is affecting things.

Thanks!








0
 
LVL 4

Expert Comment

by:abancroft
ID: 2592362
I had the same sort of problems when starting with IS - you have to get your head round the combination of file groups, components & scripts. The thing to remember is that COMPONENTS are the basic unit of work.

Anyhow, back to the question!

If you want each file group to go to a seperate (unrelated) folder, then each file group will have to go in a different component.

What's happening above is that the 'Program Files' target folder has defaulted to 'TARGETDIR' - so each file group in 'Program Files' get's copied to TARGETDIR.

TARGETDIR is just a string variable - you can assign a value to it like any other. In SetupInstall(), you'll find it is default assigned the company & project name. Just change it to whatever folder you want. e.g.
TARGETDIR = "C:" ^ "MyFolder";

It would really help me if you could layout your desired folder structure.
0
 

Author Comment

by:John500
ID: 2592736
abancroft,

The program is running correctly.  I did as you said and created five separate components.  I also made the change to TARGETDIR.

The only other thing I'm concerned about is how I can delete the existing files in the destination directorie(s).  Do I need to drum up the code for this or does InstallShield provide this functionality?  

Regarding the directory structure, I think I threw you off when I said the component name would be 'Program Files'.  That's what I had, but I see now the relevance of having five different components.
0
 
LVL 4

Expert Comment

by:abancroft
ID: 2592763
Are you overwriting the existing files?

If so, set the 'Overwrite' component property to 'ALWAYS OVERWRITE'.

If not, you will need to write the code to delete the files. The easiest solution would be to simply delete the folders in ProcessBeforeDataMove(). Of course, this may delete user data files....
0
 

Author Comment

by:John500
ID: 2593042
abancroft,

I found the property pertaining to 'Overwriting', but as you mentioned, this will only be good if the old files match the new.  I'll delete folders  within ProcessBeforeDataMove() as you suggested, but what is the function called which is used for deleting files?  Is there a list somewhere of all functions available?

0
 
LVL 4

Accepted Solution

by:
abancroft earned 200 total points
ID: 2593054
The online help has a full programming guide, including all the IS functions.
0
 

Author Comment

by:John500
ID: 2593355
abancroft,

Thanks, I'm found DeleteDir() which works fine.

I know I'm going to have more concerns here when it comes to updating the entire program.  This change was relatively small.

Can you give me something to think about regarding dlls and how that's done.  I have a program called 'modules.exe' which reveals all the DLLs used by a process.  I guess I'll need to identify the necessary dlls and package them, right?

I'll start a new question, but in the mean-time...
0
 
LVL 4

Expert Comment

by:abancroft
ID: 2593374
Using modules (or dependency walker that comes with VC) is a good start.

You'll have to decide whether to place all the DLL's in the same folder as the EXE, or put some in WINDOWS\SYSTEM. I'd recommend the former: it's much cleaner.

Watch for delay loaded or dynamically loaded DLL's that modules.exe won't find.

I usually test my installs by doing a clean installation of Win95a on a PC & then installing my app & testing it.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question