cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Rachelbaskaran
Level 5

Copy entire folder- Installshield 2009

Hey

Does anybody know how to copy an entire folder from the source directory to target location using installscript?

Thanks in advance!

Rachel
Labels (1)
0 Kudos
(34) Replies
RobertDickau
Flexera Alumni

Using InstallScript code (as opposed to a dynamic file link in an InstallScript project), you might look into XCopyFile.
0 Kudos
Rachelbaskaran
Level 5

Hey Robert,


Thanks for you reply.

I did check on the XCopyFile installscript, but I could only copy the files inside the folder to the target and not the entire folder. In the sense imagine I have a folder called ICON and few files in it. SO what XCopyFile does is that it copies the few files which is inside my folder ICON and not just the folder ICON.

Is there a way to copy the folder named ICON along with files in it to the target location.

Thanks
Rachel
0 Kudos
RobertDickau
Flexera Alumni

Hmm, perhaps put that source folder inside another folder and use XCopyFile with INCLUDE_SUBDIR; or else use CreateDir to create the ICON folder and use that as the destination?
0 Kudos
Rachelbaskaran
Level 5

Hey Robert,

Guess I have got even more bigger problem, like the one below.

How should I delay my copy file process? Becoz this is what happens when I run my installer on my PC, the script returns copy failed before my 3 exe's (Apache, MySQL & php) gets installed on my system.

Is there a way of running the script after installing the 3 exe manually( i.e double clicking )?

Also my script works only for OnBegin() function by displaying the appropriate MessageBox and it doesn't seem to work for below code

export prototype ExFn_XCopyFile(HWND);
function ExFn_XCopyFile(hMSI)

Am I missing any arguments?

Thanks!
Rachel
0 Kudos
RobertDickau
Flexera Alumni

Is this a pure InstallScript project? If so, maybe use OnMoved or one of the feature_Installed events?
0 Kudos
Rachelbaskaran
Level 5

Hey Robert,

Thank you so much. Yes it's a pure Installscript project. The function OnMoved worked, also I delayed the process for few seconds.


But the weird thing I notice is that when I uninstall the setup in add/remove programs. The message box "File successfully copied" shows up.

Is there any way to hide that MessageBox while uninstalling?


Thanks again

Rachel
0 Kudos
RobertDickau
Flexera Alumni

If you want the code to run only during the initial install (and not during maintenance or uninstall), perhaps wrap it in:
if (!MAINTENANCE) then
// XCopyFile, etc.
endif;
0 Kudos
Rachelbaskaran
Level 5

Hey Robert,

Thank you so much, it worked.


I waan copy or say replace the php.ini in C:\\Windows. I guess by default when I run the php exe the php.ini go to the C:\\Windows automatically. But I want the php.ini which I had modified and have inside my installer to be placed in the Windows directory.

If my client already got the php.ini in windows, I waan to replace it with the one in my installer. Is there anyway of replacing the file using the installscript?

Thanks again
Rachel
0 Kudos
RobertDickau
Flexera Alumni

Hmmm, maybe I don't understand the question, but you might look at the different flags for XCopyFile that control whether it overwrites existing files...
0 Kudos
Rachelbaskaran
Level 5

Hey Robert,


Hope this time I make it clear for you. Imagine that I want to place or say overwrite the php.ini in C:\\Windows with the php.ini file that I have inside the installer.

In the sense, my installer will contain 3 exe files and a modified php.ini file. So I waan overwrite the already existing php.ini file in C:\\Windows with the one in my installer.


Do we have any script to overwite a file in the specified target location (i.e.C:\\Windows) ?

Thanks
Rachel
0 Kudos
RobertDickau
Flexera Alumni

Hmm, does XCopyFile not work in this case?
0 Kudos
Rachelbaskaran
Level 5

Hey Robert,

My doubt is will XCopyFile, replace the already existing php.ini with the one inside my installer. In other way overwrite it.


Really? :confused:


Thanks
Rachel
0 Kudos
RobertDickau
Flexera Alumni

Yes, XCopyFile can overwrite an existing file. Please see the XCopyFile help topic for details of the flags you can pass in.
0 Kudos
Rachelbaskaran
Level 5

No, it just copies my file into C:\\Windows and not really overwrite it.

I tried with the flags

COMP_NORMAL &
COMP_UPDATE_SAME.


Should I use different flag?


Thanks
Rachel
0 Kudos
RobertDickau
Flexera Alumni

Sorry, how does it "copy but not overwrite"? Does the return value of XCopyFile tell you anything?
0 Kudos
Rachelbaskaran
Level 5

No, it just displays the MessageBox( "Files successfully copied") ( So for sure the return value is 0 )

and when I go to Windows Dir I see 2 php.ini files ( i.e. one already there and the 2nd one copied from my installer )


This is the first time I'm using Installshield , I've never worked with it before 😞
0 Kudos
RobertDickau
Flexera Alumni

Hmm, I'm not sure why there would be two copies in the same directory. Perhaps file extensions are hidden in your Windows settings, so one is really php.ini.txt or something?
0 Kudos
Rachelbaskaran
Level 5

It's php.ini.txt
0 Kudos
Rachelbaskaran
Level 5

I'm so sorry, it's just php.ini it seems.

Thanks
Rachel
0 Kudos
RobertDickau
Flexera Alumni

Thanks for the update, Rachel---does it work if the file in your project is renamed to use the same name as the existing file?
0 Kudos