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

Looking for a faster process


3 replies to this topic

Ozone

Ozone
  • Full Members
  • 77 posts

Posted 23 July 2004 - 15:07

I am in need of finding a faster method or process to determine if any file in the TARGETDIR is locked. (Includes subdirectories)

Background conditions:

1. Custom Installscript using program block scripting. So there is no ‘maintenance mode’.
2. Large project, 1500 files, 7 subdirectories. It is a full accounting, production, inventory, process control, data transfer, software package.
3. Installs to a stand alone PC, Workgroup, or Client-Server.
4. We need to make sure that no files are locked as some upgrades will run a full blown data conversion of the customer’s data files. In real life there always seems to be one workstation still logged on! Because of the data conversion possibility, we cannot just rely on re-booting after installation to install the files that were locked. Plus, if the user is installing from a workstation to a server, the locked files on the server remain locked, while the workstation re-boots.

Problem:

On slower stand alone PC’s and all Workgroups and Client-server installs, it can take up to 30 minutes for the following script to check every file in the TARGETDIR for a locked condition.

The command nvLockStatus = Is ( FILE_LOCKED , svFile ); seems to be the problem. If I remark it out, then the process takes less than 2 seconds.

NOTE: Variables in this function that are not defined in the function, are Global...

CODE

///////////////////////////////////////////////////////////////////////
//
// FUNCTION: Locked_Files()
//
//  Purpose: To check all XXXX files to see if any are locked
//
// Activated:  6-28-2001    TEB
//
///////////////////////////////////////////////////////////////////////

function Locked_Files()

STRING svFile, svStatus;
NUMBER nvLockStatus, ndResult;


begin


SdShowMsg ("Scanning " + TARGETDIR + " for locked files ..... Please wait, this may take some time.....",TRUE);

svStatus = ""; //Default value
                 
ndResult = FindAllFiles( TARGETDIR  , "*.*" , svFile , RESET );
                 
while ndResult = 0
 nvLockStatus = Is ( FILE_LOCKED , svFile );
  if svFile != TARGETDIR ^ LOG_FILE then // LOG_FILE is just created.
   if nvLockStatus = TRUE then
    Time();
    LOG_File_Create();
    WriteLine ( nvLOG_FileHandle , "The file " + svFile + " is locked. == Time: " + svTIME );
    WriteLine ( nvLOG_FileHandle , TERMINATE_MSG + svDATE + " Time: " + svTIME );
    CloseFile ( nvLOG_FileHandle );
    MessageBox ( "The file " + svFile + " is locked by some other program.\n\nLog off all users and close the Pervasive database engine.\n\nThis setup will terminate.\n\nWhen you shut down the other application, you can re-start the XXXX System Installation." , WARNING );
    abort; // Terminate the installation
   elseif nvLockStatus < 0 then
    svStatus = "Unknown";
   endif;
  endif;
 ndResult = FindAllFiles( TARGETDIR  , "*.*" , svFile , CONTINUE );
endwhile;

// Clear memory buffer
Find_All_Files_CANCEL();
 
if svStatus = "Unknown" then
 Time();
 LOG_File_Create();
 WriteLine ( nvLOG_FileHandle , "Locked_files function was unable to answer if any files were locked. " + svTIME );
 CloseFile ( nvLOG_FileHandle );
elseif nvLockStatus = FALSE then
 Time();
 LOG_File_Create();
 WriteLine ( nvLOG_FileHandle , "NO Locked files were detected. === Date: " + svDATE + "   Time: " + svTIME );
 CloseFile ( nvLOG_FileHandle );
endif;

SdShowMsg ( "", FALSE);

end;





Glytzhkof

Glytzhkof
  • Moderators
  • 1,447 posts

Posted 23 July 2004 - 15:52

Would it be possible to try and change the directory names? If you are not allowed to there should be a locked file in the folder?
Regards
-Stein Åsmul

Ozone

Ozone
  • Full Members
  • 77 posts

Posted 23 July 2004 - 20:47

I believe that this method will work. Do you know of a InstallShield script function that will rename a directory? I can probably intertwine a process involving a .dll, batch program, or VB Script to do it, but my preference would be InstallScript.

Thank you for your response! biggrin.gif I hope to return the favor some day.



Glytzhkof

Glytzhkof
  • Moderators
  • 1,447 posts

Posted 24 July 2004 - 06:03

Maybe this sample code helps: http://www.installsi...m#DirOperations
Regards
-Stein Åsmul