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
Rachelbaskaran
Level 5

Hey Robert,

I tried but doesn't seem to work.

Thanks
Rachel
0 Kudos
RobertDickau
Flexera Alumni

What is it doing now? Is it at least down to one copy of the "same" file in the Windows directory? What does the actual call to XCopyFile look like?
0 Kudos
Rachelbaskaran
Level 5

Yes, it's down to one copy. But I'm not very sure whether it overwrites the existing one.


But among this I got one major issue, to solve. After I upload the exe file inside my company's ftp site and when I download to my desktop to see whether it's working, I get this error as you see in the attached screen shot. Am I missing any file?


Thanks
Rachel
0 Kudos
RobertDickau
Flexera Alumni

For the first issue, you might verify that the overwrite works by using test files with different contents and the same name in your installer and in the Windows folder. (Another possibility is to include the INI file in a new feature and component and install it normally.)

You might start a separate thread for the other issue; and might post the media type you're using and other project settings...
0 Kudos
Rachelbaskaran
Level 5

Hey Robert,

I tried changing few value here and there and checked whether the file inside my installer gets copied but no luck.

One thing I noticed while checking on the details of the files is this

php.ini in the WINNT

Modified 6\9\2009 5:55 PM

php.ini in my installer

Modified 1\9\2009 12:57 PM


I use the below script:

if(XCopyFile(SDIR, TDIR, COMP_UPDATE_SAME) < 0 ) then
MessageBox("Copy file failed.", SEVERE);

else
MessageBox("File copied.", INFORMATION);

endif;

Also since I use XCopyFile function during uninstall my php.ini file is removed from the WINNT dir.

Any solution? :confused:

Thanks
Rachel
0 Kudos
RobertDickau
Flexera Alumni

Perhaps use COMP_NORMAL instead of COMP_UPDATE_SAME? (The XCopyFile page also mentions that COMP_UPDATE_SAME doesn't work by itself, but should be combined with COMP_UPDATE_DATE or COMP_UPDATE_VERSION.)

To prevent the file from being removed at uninstall, you can place XCopyFile between Disable(LOGGING); and Enable(LOGGING);.
0 Kudos
Rachelbaskaran
Level 5

Hey Robert,

I tried with COMP_NORMAL too, but no luck ( Don't know why ) In the previous reply you had suggested the option " To include the INI file in a new feature and component and install it normally"- How do I do that?


Also where I need to insert/add Disable(LOGGING) and Enable(LOGGING)?


Am I right, if it's the below format?


Disable(LOGGING)

if(!MAINTENANCE) then
if(XCopyFile(SDIR,TDIR, COPM_NORMAL) < 0 ) then
MessageBox("");
endif;
endif;

Enable(LOGGING)
end;


Thanks
Rachel
0 Kudos
RobertDickau
Flexera Alumni

In the Setup Design view, you set up the features and components that include the files to install.

Correct about the order of Disable(LOGGING), XCopyFile, Enable(LOGGING).

If you display a MessageBox on XCopyFile success, does it show up? (That is, is XCopyFile being called at all?)

One further possibility is that InstallScript has some INI functions, with which you can modify the INI file directly without copying over it...
0 Kudos
Rachelbaskaran
Level 5

Hey Robert,

Yes, it displayed the message box("Files are copied");

I don't want to complicate by changing values of php.ini ( already in the c:\\windows) through INI file. All I want is copy the modified php.ini to copy/replace the one in the C:\\Windows.

Thanks
Rachel
0 Kudos
RobertDickau
Flexera Alumni

If this is your actual code---
if(XCopyFile(SDIR,TDIR, COPM_NORMAL) < 0 ) then
---how are you setting SDIR and TDIR? Maybe the file is going to the wrong place.
0 Kudos
gavin_landon
Level 6

Couldnt you just use the following:

set filesys=CreateObject("Scripting.FileSystemObject");
if(IsObject ( filesys )) then
if(filesys.FolderExists("c:\\tester\\aa")) then
filesys.CopyFolder("c:\\tester\\aa", "c:\\tester\\bb");
MessageBox("copy success", INFORMATION);
else
MessageBox("c:\\tester\\aa does not exist.", SEVERE);
endif;
else
MessageBox("Failed to create FSO", SEVERE);
endif;
0 Kudos
Rachelbaskaran
Level 5

Hey Robert,

It's

SDIR "C:\\Program Files\\company name\\copy(installer name)\\ICON\\php.ini"
TDIR "C:\\Windows"


if(XCopyFile(SDIR,TDIR,COMP_NORMAL) < 0) then
MessageBox("Copy failed.", SEVERE);

else
MessageBox("File copied.", INFORMATION);
endif;
end;


ICON is the folder where I added it to be the part of my installer along with 3 exe's. The folder which contains the files and folders to be copied to the client's system.


Gavin, yet to try yours.

Thanks
Rachel
0 Kudos
Rachelbaskaran
Level 5

Hey Robert,

I think you previously told me that If I use Disable(LOGGING),XCopyFile,Enable(LOGGING), I can avoid the php.ini file or whatever file that's been copied during the installation being deleted during the uninstall.

So in my installer I have couple of elseif to work with and so, my script would be something like this

if(!MAINTENANCE) then
if(XCopyFile(..........))
elseif(XCOpyFile(.....))

Disable(LOGGING);

elseif(XCopyFile(SDIR,TDIR,COMP_NORMAL) then
MessageBox("");
endif; //endif for the if statement
endif; //endif for the outer if statement( i.e. if(!MAINTENENCE) )

Enable(LOGGING);
end;

Am I using the flags in the wrong places. Coz the file gets deleted after uninstall.


Also, I solved the copy issue of the php.ini thing. What I did was this, since I go for self-extraction of php before copying the files, for sure PHP places the php.ini file in windows dir. So I wrote a script to delete the existing one and then copy the file from my installer and it worked.


Thanks
Rachel
0 Kudos
RobertDickau
Flexera Alumni

Very strange that you'd need to delete the file before XCopyFile works, but I'm glad that's working.

And Disable(LOGGING) should run before the XCopyFile you want to be permanent, so as long as your logic flows that way...

(For testing, you might consider making a simple InstallScript project with two XCopyFile calls, one with normal logging and one with logging disabled, to demonstrate the expected behavior.)
0 Kudos