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

AreFilesLocked()


7 replies to this topic

Xitch13

Xitch13
  • Members
  • 134 posts

Posted 09 August 2002 - 16:37

I've written a Patch to the software that our field installers use.  It's designed to be silent and not to cause a reboot.  Unfortunately, sometimes when they are installing the Patch on our Servers, some of the resources are still being used.  This causes a File_Locked condition, obviously, which the Patch handles by automatically answering the warning and setting a flag to reboot.  The field installers would much prefer to find out beforehand and release the resources by hand.

Now, I have come up with a way to do this:
1. Create a list BY HAND of all files in Patch, approx 40 - 50 files
2. In a while loop, send each file to a CheckForLocked()
3. If the file is locked, set flag and add name to end of a string
4. If flag is set, then display list and offer to abort

That's not a terrible way of solving the problem, except I believe I have to update the list by hand.  Is there a function that can sniff all the files included in the installer (wether or not they'll be used does not matter to me) and puts them into a list?

Or better yet, is there a more elegant solution to my problem?
(i've already tried some tests with the OnFileLocked() - it's too late to abort after some files have already been put down)

Any help would be appreciated.  Thank you.

Please post answers here for posteriety, but if there are other resources on the web you can email me at ccrook@catechnology.com


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

Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 09 August 2002 - 19:16

Well I guess the first question would be why are the files locked or in use.  Is it because your software is running, because it includes system files, or a little of both?

Because it would be easier to just see if certain processes are running and either make the user shut them down or kill them yourself.  An example of how to do so is List and Shut Down Running Applications.
user posted image

Xitch13

Xitch13
  • Members
  • 134 posts

Posted 09 August 2002 - 19:27

I'm not really worried about services or dll that the system itself is using currently.  I already end those without a problem.  My trouble comes usually from a client holding onto a resource.  Checking store video or another database.  Even if someone had requested video and did not shut down properly, the resource still shows it's in use.  Hence, the need to check for locked files


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

Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 09 August 2002 - 19:42

Ahh yes, this is a server, so I understand your dilema.

I don't know of any file group type functions, so one option could be to leave your data files uncompressed. Then at install time get a listing of what's in that uncompressed directory and go from there.
user posted image

Xitch13

Xitch13
  • Members
  • 134 posts

Posted 09 August 2002 - 19:48

That sounds like a great idea.  Unfortunately, I don't think the installers will go for it.  The wanted the Patch as small as possible to be able to download it quickly at sites, some of which only have dial-up connections (heathens!;).

Thank you for all your help (and future help :-) ).  I've been impressed by many of your answers on other threads.
There is great chaos under heaven, and the situation is excellent. (Mao Tse Tung)

Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 09 August 2002 - 20:30

Understandable, but you could still package it up as a single executable using either the option in your media definition or using PackageForTheWeb.  I think that will also do some level of compression.

You could also try zipping the setup, an if you prefer making it a self-extracting executable, before posting it to the Internet.

---

You're welcome for the help though, and thanks for the compliments.  I try to help out people when I can, so we can all learn from one another.
user posted image

Xitch13

Xitch13
  • Members
  • 134 posts

Posted 14 August 2002 - 20:02

THis is not an answer on how to list all files in the installer.  I still haven't found the perfect solution yet for that, but wanted to display how I'm solving the check for locked files for now.
Code Sample

////////////////////////////////////////////////////////////////////////////
//
//  FUNCTION: CheckFilesForLocked()
//
//  PURPOSE: To call all files potentially replaced by Patch and check
// for locked comndition.  If a file is locked, the function  
// will report this to the user and allow an abort if requested
//
// CONCERN: THE FILE LIST MUST BE MANUALLY UPDATED.  IF A FILE IS ADDED
// TO INSTALLER, IT MUST BE ADDED HERE
//
///////////////////////////////////////////////////////////////////////////

function CheckFilesForLocked()

STRING szFilesLocked, szFile, szMsg1, szMsg2;
NUMBER nResult, nLockedResult;
BOOL bFileLocked;
LIST listFiles;


begin
// give variables intial value
bFileLocked = FALSE;
szFilesLocked = "";  

// Build list                  
listFiles = ListCreate(STRINGLIST);  
ListAddString (listFiles, "\\FileOne.dll", AFTER);
ListAddString (listFiles, "\\FileTwo.dll", AFTER);
ListAddString (listFiles, "\\FileThree.exe", AFTER);
ListAddString (listFiles, "\\....dll", AFTER);
ListAddString (listFiles, "\\Sub Folder\\FileSOmeNumber", AFTER);
            ...
            ...
ListAddString (listFiles, "\\FileLast.dll", AFTER);


// Check each item in list for Locked Files
// if one is locked set flag and add name to string
nResult = ListGetFirstString (listFiles, szFile);
   while ( nResult != END_OF_LIST )
    nLockedResult = IsFileLocked(TARGETDIR + szFile);
if (nLockedResult = 1) then
bFileLocked = TRUE;
szFilesLocked = szFilesLocked + szFile +"\n";
endif;
nResult = ListGetNextString(listFiles, szFile);  
endwhile;


//if flag is tripped then inform user which files and allow
//  a reboot
if (bFileLocked = TRUE) then
szMsg1 = "The above file(s) is(are) currently locked.  If you continue with installtion\n";
szMsg2 = ", a reboot will be necessary.  Click YES to continue, NO to abort installation.";
       nResult=AskYesNo (szFilesLocked + szMsg1 + szMsg2, YES );
       if nResult = NO then
      abort;
  endif;    
   endif;

// release resource
ListDestroy (listFiles);

end;




//////////////////////////////////////////////////////////////////////////////
//                                                                          
//  FUNCTION:   IsFileLocked                                          
//                                                                          
//  PURPOSE:    To determine if a file is currently locked.
//
//  RETURN: 0 if it is not locked
// 1 if it is locked
// <0 if it is unable to answer question
//                                                      
///////////////////////////////////////////////////////////////////////////////
function IsFileLocked(szFile)

NUMBER nResult;

begin
nResult = Is (FILE_LOCKED, szFile);  
return nResult;
end;





Hope this helps someone :)


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

Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 15 August 2002 - 06:29

Another option so you don't have to manually maintain that list is to include a copy of the IS report or log file.  One of those, I forget which at the moment, has a complete listing of all of the files along which a bunch of other information.

You'll need to parse through all that, but at least it would have to then be manually kept up-to-date.

You would need to make a copy of the ile though and place it along side your setup, so it's available come install time.
user posted image