Solved

InstallShield - Setting The Destination Path

Posted on 2000-03-06
16
3,273 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

628 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