Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

How to copy from [INSTALLDIR] ?


11 replies to this topic

technojewel

technojewel
  • Members
  • 17 posts

Posted 14 February 2006 - 09:10

I am using Installshield 11.5 Pro and working on Basic MSI Project.

I have made a script (courtesy and thanks to sebica79). It checks a particular registry entry and copies a file. I have placed this script in the Install Exec sequence at "After InstallFiles". What I want is to copy a file (named "bugs desc.txt") from [INSTALLDIR] to my desired folder in the system. I am not sure how to copy the file from [INSTALLDIR]. I have tried the following options but none of them worked:

1.) XCopyFile ( "[INSTALLDIR] ^ bug desc.txt", "E:\\Program Files\\My App\\Test", COMP_NORMAL );

2.) XCopyFile ( "[INSTALLDIR]\\bug desc.txt", "E:\\Program Files\\My App\\Test", COMP_NORMAL );

This:
XCopyFile ( [INSTALLDIR] ^ "bug desc.txt", "E:\\Program Files\\My App\\Test", COMP_NORMAL );
gives me error saying '[' missing.

So can anyone tell me how can I copy a file from [INSTALLDIR] using xCopy Command (or some other command).

Thanks in Advance.


ali

ali
  • Full Members
  • 1,008 posts

Posted 14 February 2006 - 10:38

you can use the MoveFiles Table in the Direct Editor to Copy Files from Installdir to another Folder.

technojewel

technojewel
  • Members
  • 17 posts

Posted 14 February 2006 - 10:49

But, I want to copy the files conditionally. I am actually checking a registry entry. If found then only I am copying the files. So I have written the script to check the registry and then copy files if its found.

Can we do this using the MoveFiles table?


ali

ali
  • Full Members
  • 1,008 posts

Posted 14 February 2006 - 12:19

you can do this like a Dummy Component and it conditions. If the Component is selected to install, the installer copys the File you've filled in the Move File Table.
you can delete the File with a entry in the Remove File Table and the Name from the Componet in the componet colum. If the installer remove the Component the File will be delete too.

Edited by ali, 14 February 2006 - 12:20.


technojewel

technojewel
  • Members
  • 17 posts

Posted 14 February 2006 - 12:54

Sorry, but I could not get you sad.gif. Seems I am too novice for this.

Here is my script:

function MyFunction(hMSI)
// To Do: Declare local variables.
NUMBER nResult, nVersion, nType, nvSize;
STRING szName, szValue;
begin

// To Do: Write script that will be executed when MyFunction is called.


RegDBSetDefaultRoot( HKEY_LOCAL_MACHINE );
if ( RegDBKeyExist( "SOFTWARE\\Microsoft\\MediaPlayer\\9.0\\Registration" ) < 0 ) then

MsiSetProperty( hMSI,"COPYSUCCESS", "0" );
else
// theproduct was found
MsiSetProperty( hMSI,"COPYSUCCESS", "1" );

XCopyFile(INSTALLDIR^"bug desc.txt", "E:\\Program Files\\MyApp\\Test", COMP_NORMAL );
endif;


end;

Why is it not copying the file from INSTALLDIR to my desired location?

Please suggest me what should I do in my script.

ali

ali
  • Full Members
  • 1,008 posts

Posted 14 February 2006 - 13:25

MsiGetProperty(hMSI,"INSTALLDIR",szInstDir,nvCount);
XCopyFile(szInstDir^"bug desc.txt", ProgramFilesFolder, COMP_NORMAL );

By the Way:
for this you can use the System Search Funktion from IS:

RegDBSetDefaultRoot( HKEY_LOCAL_MACHINE );
if ( RegDBKeyExist( "SOFTWARE\\Microsoft\\MediaPlayer\\9.0\\Registration" ) < 0 ) then

MsiSetProperty( hMSI,"COPYSUCCESS", "0" );
else
// theproduct was found
MsiSetProperty( hMSI,"COPYSUCCESS", "1" );

Edited by ali, 14 February 2006 - 13:26.


ezrali

ezrali
  • Members
  • 12 posts

Posted 14 February 2006 - 16:34

By the way
INSTALLDIR is a special property. You don't have to get it with MsiGetProperty.
You can just use it (unwraped with []):

myFile = INSTALLDIR^"mtFile.txt";
and even set it:
INSTALLDIR = "C::\\myPath\\";

SUPPORTDIR acts the same.



ali

ali
  • Full Members
  • 1,008 posts

Posted 14 February 2006 - 16:51

you can get it with MsiGetProperty. I do this in any scripts from my Projekt. but change INSTALLDIR will change all Propertys from Components in the Project who linked with the INSTALLDIR Property in the Directory Table.

Edited by ali, 14 February 2006 - 17:00.


ezrali

ezrali
  • Members
  • 12 posts

Posted 16 February 2006 - 15:35

Yes,
I just mentioned it as an easier way to get (and set) the specific property: "INSTALLDIR".
You don't have to use msigetproperty, U can just use it as a string variable.

technojewel

technojewel
  • Members
  • 17 posts

Posted 20 February 2006 - 11:29

Sorry people. Nothing is working. I have tried all the suggestions, still its not working. I have also used a file which has got no whitespaces in its name. Still it cannot be copied.

Please help.

ali

ali
  • Full Members
  • 1,008 posts

Posted 20 February 2006 - 11:54

perhaps its an error in ur Custom Action or the position in the Sequenz you ve inset the CA!?

Edited by ali, 20 February 2006 - 11:55.


Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 20 February 2006 - 20:34

Is your custom action scheduled for Immediate execution? In this case the files are not yet installed when your custom action runs. See this article for the explanation why:
Installation Phases and In-Script Execution Options for Custom Actions in Windows Installer
http://www.installsi...00108/index.htm

Or is your custom action scheduled for deferred execution? Deferred actions don't have access to INSTALLDIR and other properties. For a workaround search msi help for CustomActionData.

The easiest solution might be to move your custom action after InstallFinalize. I assume you don't want those copied files to be removed during uninstall?