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

Copy files into D drive or C drive based on availability of D drive.

Our Requirment:

1. Check if 😧 drive is present or not.
2. If present, then copy files into D:\Folder1 or else into C:\Folder1

I tried copying files using Files & Folders section. But there was no way over there to acheive the desired conditional copying.

Thanks,
Pavan
Labels (1)
0 Kudos
(1) Reply
ITI_Randy
Level 6

PavanKumar1234 wrote:
Our Requirment:

1. Check if 😧 drive is present or not.
2. If present, then copy files into D:\Folder1 or else into C:\Folder1

I tried copying files using Files & Folders section. But there was no way over there to acheive the desired conditional copying.

Thanks,
Pavan



Go to the direct editor Directory table and add a folder for something like "CUSTOMVOLUME" and set the Directory_Parent to WindowsVolume as the default value.

You will need to check for a valid disk that is static, so you'll want a function to verify that there is a static D drive available, something like -

prototype BOOL IsValidDisk(HWND, STRING);

function BOOL IsValidDisk(hMSI, sDisk)
STRING sTestVolume;
BOOL isValid;
NUMBER nResult;
begin
try
isValid = FALSE;
sTestVolume = sDisk + ":";
if (GetSystemInfo (DRIVE, nResult, sTestVolume) >= 0) then
//IS_FIXED = 4, IS_CDROM = 6
if (nResult = IS_FIXED) then //Dirve is fixed
isValid = TRUE;
endif;
endif;
return isValid;
catch
endcatch;
end;

You'll need a method to check and set the disk, something like -

export prototype SetCustomDir(HWND);

function SetCustomDir(hMSI)
begin
//Disk is WindowsVolume by default,
//but if available, switch to D:\
if IsValidDisk(hMSI, "D:") then
MsiSetTargetPath(hMSI, "CUSTOMVOLUME", "D:\\");
endif;
end;

Any component with a root value of [CUSTOMVOLUME] will get the path you set in your custom action. You can set the InstallDir in your general properties to have a value of [CUSTOMVOLUME] if you wish, which will send everything to that drive. (Note that when you switch the InstallDir to [CUSTOMVOLUME] and click away from it, it will show WindowsVolume, indicating that the value equates to the default WindowsVolume, but this will change when the custom action runs if a static 😧 drive is available.

One final thing, schedule your customer to run at the appropriate time -

In the UI Sequence, run it early after CostFinalize
In the Execute sequence, After InstallValidate (condition: REMOVE <> "ALL")
Immediate Execution, Execute Only Once
0 Kudos