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

Copying Files Problem


8 replies to this topic

CDOSRUN

CDOSRUN
  • Members
  • 4 posts

Posted 01 April 2003 - 21:41

Hi everyone,

I need help, I am trying to write an install shield file that will simply place a .txt file in the end user machine.  I try using the Copy function in the function OnFirstUIBefore(), but it never works.

Anyone got any ideas?  I am pretty new to IS.

Thanks.

Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 02 April 2003 - 02:46

Please provide us a copy of the exact call you are trying to make and the surrounding code.

You probably forgot to use double backslashes to represent one backslash, to use the full path, or something simple like that.
user posted image

CDOSRUN

CDOSRUN
  • Members
  • 4 posts

Posted 03 April 2003 - 17:12

all i want my program to do is to put a small text file in a folder that i create on the end-user's drive.  I placed the text file in the Other part of Setup Files.  I use the following code in my OnFirstUIBefore():

Disable(LOGGING);
TARGETDIR = "C:\\SAMPLEFILE";
CopyFile("Myfile.txt","MyFile.txt");

I created single executable file on my media.  The exe creates the folder and places the file in correctly, yet i see that there is a TestApp.exe program in my Add/Remove Programs dialog.  This is what i don't want to happen.  I just want the program to simulate a act of moving a file from the disk to the folder.  I added a ComponentRemoveAll(); call at the end of OnFirstUIAfter(); but i am not sure if this is the correct way to go.  I also want the setup to always overwrite the file and never uninstall anything.

Thanks.

Xitch13

Xitch13
  • Members
  • 134 posts

Posted 03 April 2003 - 17:54

So it is doing what you want it to do?   Creating the folder and putting your file where you need it?

You're real problem is that the set-up is putting something in the add remove programs.  IS automatically does this for all install, which is what you're program is.  You can remove the registry entry that feeds the Add/Remove applet.

To remove the entry from Add/Remove Programs use
Code Sample


   //////////Removing GUID key from the registry///////////
   szSubKey= "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{Your GUID}";
   
   
   if (RegDBKeyExist(szSubKey) > 0) then
       nResult = RegDBDeleteKey (szSubKey);
        if(nResult < 0)then
        MessageBox("Unable to delete GUID key.", WARNING);
        endif;
   endif;
   /////////////////////////////////////////////////////////////////////
   


Your GUID can be found under Menu item Project/Settings/Application and is listed as GUID.


You may also want to remove the GUID from IS's history as well.  If you don't any subsiquent runnings of your set-up will go into 'Maintenace mode'.

To remove it from IS's history use:
Code Sample

////////////////Removing GUID information from Installshield directory///////////
   szPath= PROGRAMFILES + "\\InstallShield Installation Information\\{Your GUID}";
   
   nResult = ExistsDir (szPath);
   if (nResult = 0) then
       nResult = DeleteDir(szPath, ALLCONTENTS);
       if (nResult <0 ) then
        MessageBox("Unable to delete GUID information.", WARNING);
       endif;
   endif;


HTH
There is great chaos under heaven, and the situation is excellent. (Mao Tse Tung)

CDOSRUN

CDOSRUN
  • Members
  • 4 posts

Posted 15 April 2003 - 20:18

Thanks alot for the help, my setup program can now copy the file where I want it. But now I have this problem:

Whenever I try to run the install program on a different computer, I get this message:
"Error Installing iKernel.exe"

I think this may be an administrative privilege problem, how can I get around it? I figured I would have no such problems considering I am only just copying files. Any help would be really appreciated.

Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 16 April 2003 - 02:51

Sorry, but _every_ IS setup needs iKernel.exe to be installed, regardless of how simple the script may be, and doing this requires Administrator privileges.
user posted image

vidyak

vidyak
  • Members
  • 5 posts

Posted 16 April 2003 - 13:58

Hi

While we are on the topic, can somebody pls. answer another question about copyfile?

My installation tries to replace a file, but for some reason if install fails, this change is rolled back(May be by design). My problem is though installshiled takes out the newer file, there is no way to recover the file it already replaced and user is left with a missing file.

I tried to make a copy of the file by renaming it before replacing, but even the renamed file is lost on 'abort'.
Is there any way out or am I missing something obvious? I am not very well versed with IS.

Thanks in advance.

Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 16 April 2003 - 15:08

The roll back behavior on Abort/Cancel is automatic and true for all IS setups.

One thing you could try is to wrap those calls in Disable(LOGGING) and Enable(LOGGING), but even that may not work. Sorry.

Edited by TacoBell00, 16 April 2003 - 15:08.

user posted image

Scott Mayham

Scott Mayham
  • Full Members
  • 54 posts

Posted 25 April 2003 - 13:31

Toggling Enable/Disable logging will most certainly work. I use it quite often to sidestep IS's default behavior.

For example, to ensure that the user's previously-existing file is protected, follow these steps:

in OnFirstUIBefore, just before the end (and thus before file transfer begins):

Disable (LOGGING);
<copy the file to something like "file.bak">
Enable (LOGGING);

This will make a backup copy which will NOT be deleted by IS upon Uninstall/Cancel, as it has not been logged.

In MaintUIAfter, which executes just after your uninstall has removed the files you placed on the user's machine, you can reverse the above process by:

<rename the backup file to it's original name>

Logging is a handy behavior, but it is normal to have to exempt certain things from it. For example, if on NT/W2K/XP you update the System's "Path" Environment Variable, upon uninstall IS will delete the entire EnvVar, not just the part of the path you added, since what it logged was the fact that you wrote out the entire new value. Thus, I disable logging during such an update, and then have to undo the update in my script upon uninstall. On the other hand, I wish there were some things that I COULD log, such as secondary installs (via some batch or MSI launched via _LaunchAppAndWait), but, alas, IS has no idea what they do, so I must take care to undo such things where appropriate when uninstalling.

Regards,
T. Scott Mayham
Senior Software Engineer - Innovations
678 319 8384
Scott.Mayham@Infor.com