• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3634
  • Last Modified:

InstallShield - Setting The Destination Path

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
John500
Asked:
John500
1 Solution
 
ahalyaCommented:
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
 
abancroftCommented:
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
 
abancroftCommented:
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
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
jkrCommented:
abancroft is right, setting

TARGETDIR="c:\\whatever";

in your script is sufficiant...
0
 
abancroftCommented:
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
 
John500Author Commented:
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
 
abancroftCommented:
You have to do it before you call ComponentMoveData() - I would recommend in ProcessBeforeDataMove().

0
 
John500Author Commented:
Adjusted points to 200
0
 
John500Author Commented:
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
 
abancroftCommented:
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
 
John500Author Commented:
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
 
abancroftCommented:
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
 
John500Author Commented:
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
 
abancroftCommented:
The online help has a full programming guide, including all the IS functions.
0
 
John500Author Commented:
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
 
abancroftCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now