cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
DLee65
Level 13

How to check for disk space using script defined features

I have run into a problem when trying to check for available disk space on a user's machine. In this standard Installscript project I have four different destination directories.

Dir1 = TARGETDIR; (570MB)<== User can specify a different TARGETDIR;
Dir2 = DocumentsDir; (up to 178MB) <== User can change default location for documents.
Dir3 = [CommonFiles]\DeLorme (35MB)<== User CANNOT change location for these files
Dir4 = MapDataDir; (0 - ~4GB)<== User can specify a different directory, default is TARGETDIR.

Dir1, 2 & 3 are part of the setup and have features associated with each.
Dir4 is dynamic based upon what is bundled with the software (EAST, WEST, NATIONAL). This is the script defined feature.

When I check for disk space now it seems like the setup is checking the file media library first and says that target destination for each feature has enough disk space. It then checks the script defined media library and then passes that library. Never does it combine the file media library and script media library; so sometimes it allows me to start installing when in reality there is not enough room for both media libraries on the same disk.

Right now I have a convoluted and error prone method in place that combines the two media libraries into a single script defined media library but I just realized that my approach is flawed because I assume that all features are being installed to the same location. I also don't take into account if the target for each feature is found on the same disk as the SupportDir - and I will need extra space for setup to run when moving files from DVD to the hard disk.

Is there an easier method that I am missing to evaluate total disk space required for all media libraries? I would think that something like this would be standard in InstallShield but I have yet to come across it. In any case I cannot ship a setup that will lower a user's disk space to an unsafe level - the user should NEVER see the low disk notification while installing a program.
Labels (1)
0 Kudos
(2) Replies
gridman
Level 8

I imagine if you are familiar with InstallScript installations that you already know about GetDiskSpaceExe. That is what I have used in the past.
0 Kudos
DLee65
Level 13

Actually this has been deprecated in favor of the struct GetDiskInfo.

	// init. _DISK_INFO members: what drive, what info
di.szDiskPath = p_strDirectory;
di.nInfoToQuery = DISK_INFO_QUERY_DISK_FREE_SPACE;

n = GetDiskInfo(&di);

n = ConvertSizeToUnits( di.nFreeSpaceHigh, di.nFreeSpaceLow, BYTES,
nSizeTargetHigh, nSizeTargetLow, nTargetUnits);



However, I think I figured out the solution to my problem.

I need to add the cost of my script defined media library to the file media library. Then I can check the disk space requirements for the entire file media library that will consider the cost for all features/components and their respective destination directories.

So, my convoluted solution may have just got a whole lot simpler. 🙂 Thanks for the reply.

If that does not work then I will call FeatureGetCostEx for all possible drives. In this case I would call this four times, once for the four possible install paths as indicated above.
0 Kudos