Solved

InstallShield - Setting The Destination Path

Posted on 2000-03-06
16
2,984 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 86

Expert Comment

by:jkr
Comment Utility
abancroft is right, setting

TARGETDIR="c:\\whatever";

in your script is sufficiant...
0
 
LVL 4

Expert Comment

by:abancroft
Comment Utility
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
Comment Utility
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
Comment Utility
You have to do it before you call ComponentMoveData() - I would recommend in ProcessBeforeDataMove().

0
 

Author Comment

by:John500
Comment Utility
Adjusted points to 200
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:John500
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
The online help has a full programming guide, including all the IS functions.
0
 

Author Comment

by:John500
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now