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

Help!  FileDeleteLine not working!


10 replies to this topic

kris

kris
  • Members
  • 77 posts

Posted 18 August 2001 - 23:20

Hi.....I am trying to get FileDeleteLine to work for me......my main goal is the following.  There is a file on the users system that I edit on installation by adding one line to the file.  When I uninstall, I would like to remove this line that I put in during install.  So, I do a FileGrep for it, and if it exists, I try to do a FileDeleteLine.  Well, the problem is that the file I try to delete the line from must exist in SRCDIR.  So, before I do FileGrep/FileDeleteLine, I do a copy file to the SRCDIR.  The code is as follows:

test = CopyFile(path, SRCDIR^"\\file.conf");

if(FileGrep(path, searchstring, returnline, linenumst,      RESTART)==0) then

linenumend = linenumst + 1;
test = FileDeleteLine("httpd.conf", linenumst, linenumend);

endif;  

test = CopyFile("httpd.conf", path);

So, I copy the file to SRCDIR (get a good return code on that) then filegrep for my line to delete (get good return code) then do a FileDeleteLine (and I get a -2 can't find file error) then try to copy the should-be-edited file back to my directory and I get a funky -267XXXXXX  error!!  

Is my problem that SRCDIR is not found or is it a FileDeleteLine problem?

Confused!


Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 19 August 2001 - 08:04

In your CopyFile command you rename the file to file.conf. But in your FileDeleteLine you try to delete from httpd.conf.

kris

kris
  • Members
  • 77 posts

Posted 20 August 2001 - 13:56

Sorry about that,  I typed it in wrong!!!!!!  The file names really are the same in my application.......  : )  

I think my problem is that my SRCDIR is not being resolved properly?   I think this because my FileDeleteLine is returning  -2 can't find file error (even when the filenames are the same!) : )  You see, when I do the following, I see SRCDIR is not resolved....

path2 = SRCDIR^"\\http.conf"
test = CopyFile(path, path2);

in the IS debugger path2 gets set to "\http.conf"........

How can I make use of SRCDIR?  I do have "ResolveSource" in my User Interface sequence.  And this IS code is in a cutstom action placed a few actions after the Resolve Source....


Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 20 August 2001 - 21:59

You could call MsiGetProperty to get the value of SOURCEDIR.
BTW why do you copy the file to the source directory to modify it?

kris

kris
  • Members
  • 77 posts

Posted 21 August 2001 - 14:18

Well, you see I am trying to do the following......

I edit a user's existing file on install.......when they uninstall I need the old version of the file (before my edits) back.  But, when I edit the file, I do it after Execute Action, at the end of the User Interface Sequence.  I have been unsuccessful in trying to get CopyFile to work in the UI Sequence....I think you can only use it in the Execute Sequence (?).  So, I wait till uninstall to get the old file back (I would have preferred to just save away an original copy of the file with CopyFile, but like I said I can't get it to work in the UI Sequence).  So, then during uninstall I want to use FileDeleteLine, but FileDeleteLine requires the File to exist in the SRCDIR.  So, I was going to temporarily copy my file to SRCDIR, do a FileDeleteLine on it, and then copy it back to it's original directory.  

What do you think?  Is this an acceptable path to take?

Thanks, I'll try using MSIGetProperty on SOURCEDIR!


kris

kris
  • Members
  • 77 posts

Posted 21 August 2001 - 15:49

I tried using MSIGetProperty on SourceDir, which works...but then I try to do my FileDeleteLineand it reutrns a "File not Found" error code.

I still think it is because my srcdir is not resolving correctly?


kris

kris
  • Members
  • 77 posts

Posted 21 August 2001 - 22:17

Is there any other way for me to save away a copy of a users file before editing it?  CopyFile doesn't work for some reason b/c I am attempting this in the UI sequence.

Or is there a better way for me to edit it back to normal on uninstalling like I mention in another post here?  On uninstall I attempt this in the Execute Sequence.


Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 22 August 2001 - 07:41

I'm not sure why CopyFile would fail in the UI sequence.
You can use the MoveFile table to make a backup copy of the original file before you modify it. You will still need a custom action to restore the original version upon uninstall.

kris

kris
  • Members
  • 77 posts

Posted 22 August 2001 - 16:14

Unfortunately, I can't use the MoveFile table because I am editing a file that is put on the system through another install, which is a launched .msi in the UI sequence (and MoveFiles has to occur before InstallFinalize) Good thought, though......I thought it had solved it for a few minutes!  Thanks!

I am not sure why my CopyFile is not working in the UI sequence, either.......this is my InstallScript

path = PROGRAMFILES^"\\Apache Group\\Apache\\conf\\httpd.conf";
pathdest = PROGRAMFILES^"\\Apache Group\\Apache\\conf\\httpdORIGINAL.conf";
test = CopyFile(path, pathdest);

My "test" return code is a huge negative # like -267xxxxx

This script is in a CA with immediate execution, always executing and it is insterted into the UI sequence after the Execute Action.

Any ideas?  


Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 23 August 2001 - 08:24

Does PROGRAMFILES include a valid path?

kris

kris
  • Members
  • 77 posts

Posted 28 August 2001 - 15:50

Yes, it does.

Unfortunately, although I have not been able to solve this problem, I have found a work-around. The file I am trying to back up actually saves itself as a .default file, which I did not know.  So, I can use this to get the original file back for now...