cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jlschmidt
Level 3

Installscript to check available Disk Space

We are working on getting an installscript set up to check disk space when we run our customized MSI installations. We have gotten inconsistent results with what we have so far. When I try to run it it always says the computer does not have the required disk space no matter what number I try. Someone else runs the exact same thing and it does not give him the error.

Here is the script. Any ideas?

function MyFunction(hMSI)
// To Do: Declare local variables.
string szPriVolSpaceRemaining;
number nsize;
begin

// To Do: Write script that will be executed when MyFunction is called.
nsize = MAX_PATH;
MsiGetProperty (hMSI, "PrimaryVolumeSpaceRemaining", szPriVolSpaceRemaining, nsize);
// MessageBox (szPriVolSpaceRemaining, 0);

// This checks if the available space if less than or equal to 2 GB
if (szPriVolSpaceRemaining <= '4194304') then
MessageBox ("You need 2 GB of free space to run this install. The setup will now exit! ", 0);
abort;
endif;

end;
Labels (1)
0 Kudos
(5) Replies
RobertDickau
Flexera Alumni

It might be that you're doing a string comparison between the property value and "4194304", so anything that comes earlier in alphabetical order would be "less than" that value, and anything alphabetically later would be "greater".

A couple of options might be to call StrToNum and do a numeric comparison; or call GetDiskSpaceEx and skip the property.

If you just want the installer to require some extra space, the best option might be to add a record to the ReserveCost table of your MSI database using the Direct Editor view. The MSI help library describes what to put in a ReserveCost record.
0 Kudos
MrTree
Level 6

I use

// sDir - Directory to check
// nMBytes - needed size in MB
if(GetDiskSpaceEx(sDir, MBYTES) < nMBytes) then
// do something - not enough space
endif;
0 Kudos
jlschmidt
Level 3

Sorry I am kinda new to installscripts

if i were trying to make sure the drive had at least 2 gigs of space where would I tell the script how much disk space to check for?
0 Kudos
MrTree
Level 6


if(GetDiskSpaceEx(TARGTDIR, MBYTES) < 2048) then
MessageBox("omg not enough space.", INFORMATION);
endif;
0 Kudos
zhuerbb
Level 2

RobertDickau wrote:
It might be that you're doing a string comparison between the property value and "4194304", so anything that comes earlier in alphabetical order would be "less than" that value, and anything alphabetically later would be "greater".

A couple of options might be to call StrToNum and do a numeric comparison; or call GetDiskSpaceEx and skip the property.

If you just want the installer to require some extra space, the best option might be to add a record to the ReserveCost table of your MSI database using the Direct Editor view. The MSI help library describes what to put in a ReserveCost record.


great!!
Thanks!
0 Kudos