Jump to content
Sign in to follow this  
saywell

Fileinstall() error

Recommended Posts

saywell

Hi,

I've got a piece of code I use in modified form in a variety of applications.

For some reason, one application has started to fail to compile due to the error in the title. It relates the error to encrypt.ibb but if I take that line out it will relate it to the next fileinstall and so on.

I have compiled this script successfully in the past, and recent changes have not included this section.

The relevant piece of the function is quoted:

Func createencreypted()
;Note: at this point @GUI_CTRLID would equal $okbutton,
;and @GUI_WINHANDLE would equal $mainwindow
;$sCDdrive = IniRead(@ScriptDir & "\config\encryption.ini", "CDdriveLetter", "CD","E")
  
    Run (@ScriptDir & "\cd_encryption\progress.exe")
;MsgBox(0, "Encrypting", "Creating Encrypted CD."  & @CRLF & @CRLF & "Please ensure that a blank CDR is in the drive" & @crlf & "and the Impax CD Wizard is running but paused at the Warning Message"   & @CRLF & " " & @CRLF &  "If not already done, Activate Impax CD Burn Wizard in the usual way"  & @CRLF & "but DO NOT click OK in the Warning Impax dialogue box")
  
  If WinExists ("Warning", "Please ensure that a blank") Then
    WinActivate ("Warning", "Please ensure that a blank")
    WinSetState ("Warning", "Please ensure that a blank", @SW_MINIMIZE)
    Sleep (25)
    Else
    MsgBox (0, "Query?", "Has Impax CD Wizard been initiated?" & @CRLF & " " & @CRLF & "If not - do so now but do not click OK on the Impax Warning Message"  & @CRLF & " " & @CRLF & "Then click OK here when ready")
    EndIf

  FileInstall ( "7Za.exe", @ScriptDir & "\" ,1)
  FileInstall ( "encrypt.ibb", @ScriptDir & "\", 1)

Any thoughts on what is wrong here?

And yes, the programs to be installed are sitting in the same folder as the script, and indeed other scripts with the same bit of code in them compile fine!

Thanks for your help.

William

Edited by saywell

Share this post


Link to post
Share on other sites
Jos

Does it fail when compiling this code section ?

If not you need to post a piece of code that replicates the shown error.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
saywell

Does it fail when compiling this code section ?

If not you need to post a piece of code that replicates the shown error.

Jos

Jos, thanks.

yes, this bit does compile OK, but it's the only section where the fileinstall is used.

below is the whole function, which doesn't compile standalone [note you have to ignore the undeclared global variables which are present earlier in the script]

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <file.au3>
#include <String.au3>
#Include <Array.au3>
#Include <IE.au3>
#include <Process.au3>


Func createencreypted()
 
  
    Run (@ScriptDir & "\cd_encryption\progress.exe")
  
  
  If WinExists ("Warning", "Please ensure that a blank") Then
    WinActivate ("Warning", "Please ensure that a blank")
    WinSetState ("Warning", "Please ensure that a blank", @SW_MINIMIZE)
    Sleep (25)
    Else
    MsgBox (0, "Query?", "Has Impax CD Wizard been initiated?" & @CRLF & " " & @CRLF & "If not - do so now but do not click OK on the Impax Warning Message"  & @CRLF & " " & @CRLF & "Then click OK here when ready")
    EndIf

  FileInstall ( "7Za.exe", @ScriptDir & "\" ,1)  
 ;FileInstall ( "CreateCD.exe", @ScriptDir & "\" ,1)
  FileInstall ( "encrypt.ibb", @ScriptDir & "\", 1)

  
  $stringTest = @year & @mon & @mday
;MsgBox (4096, "date string", $stringTest)
$sTest2 = 0
$sTest2 = FileExists ($sSourcePath & $stringTest & "*")  
    If $sTest2 = 0 Then
        MsgBox (4096, "Query?", "Has Impax CD Wizard been initiatied?" & @CRLF & @CRLF & "If not - do so now but do not click OK on the Impax Warning Message" & @CRLF & @CRLF & "Click OK here when ready to proceed with encryption")
        $sTest2 = FileExists ($sSourcePath & $stringTest & "*")
    EndIf
While $sTest2 = 1
$search = FileFindFirstFile($sSourcePath & "\*.*")  

    If $search = -1 Then
        MsgBox (4096, "Error", "Folder not found" & "CD will not be created")
    EndIf
    

    Do
    $folder = FileFindNextFile($search) 
    If $search = -1 Then ExitLoop
    $sTest = StringInStr ($folder, $stringTest)
    Until   $sTest = 1
    
;MsgBox(4096, "Foldername", "Folder Name is: " & $folder); can be removed at end of test period
;WEnd

; Close the search handle
FileClose($search)
  $sAgfaCDfolder = $sSourcePath & $folder
  MsgBox(4096, "FullPathName", "Path Name is: " &$sAgfaCDfolder); can be removed at end of test period
  DirCreate ("c:\burn")
  DirCreate ("c:\cd_temp")
  
 ;*************************************
 ;next bit deals with subfolder
 ;*************************************
 ;Copy known stuff to c:\burn leaving only the randomly-named folder                     ************** TO DO  *************************
  
 ;find subfolder
  $search2 = FileFindFirstFile($sAgfaCDfolder & "*") 
  If $search2 = -1 Then
        MsgBox (4096, "Error", "Folder not found" & "CD will not be created")
    EndIf
    
    
    $sSubFolder = FileFindNextFile ($search2)
    If @error Then 
    MsgBox(4096, "Error:", "exitloop")
    ExitLoop
    EndIf

    MsgBox(4096, "Subfolder found:  ", $sSubFolder)
 ;copy subfolder stuff to c:\burn
  
 ;********************************
  
 ;  Section to get directory
  
 ;*********************************
  
  $sDirectoryList1 = $sAgfaCDfolder & "dir.bat"
  $sDirectoryList2 = $sAgfaCDfolder & "dir.txt"
  FileInstall (@ScriptDir & "dir.bat", $sDirectoryList1,1)
  RunWait ($sDirectoryList1)
  FileCopy ($sDirectoryList2, @DesktopCommonDir)
    
 ;********************************
  
 ;  End of Section to get directory
  
 ;*********************************
  
  FileDelete ($sAgfaCDfolder & "autorun.inf")
  DirCopy ($sSubFolder, "c:\burn");  check we don't need to remove anything more first
  
;  *********************************************************************
  
      DirCopy ($sAgfaCDfolder, "c:\burn", 1) ; Files copied, ready to encrypt and burn

  FileSetAttrib ($sAgfaCDfolder & "*.*", "-RASH", 1)
  DirRemove ($sAgfaCDfolder, 1)

    If WinExists ("Warning", "Please ensure that a blank") Then
    WinActivate ("Warning", "Please ensure that a blank")
    WinSetState ("Warning", "Please ensure that a blank", @SW_RESTORE)
    Send ("{ENTER}")
    
    Sleep (1000)
    EndIf
    $sTest3 = WinExists("Warning", "Please ensure that a blank")
    If $sTest3 = 1 Then
        MsgBox (0, "User Intervention Required", "Please click OK in the Impax WARNING dialogue box" & @CRLF & " " & @CRLF & "Then click OK here to proceed")
    EndIf
    
    WinWaitActive ("Error", "Error writing CD, cancelling", 5)
    
    If WinExists ("Error", "Error writing CD, cancelling") Then
    WinActivate ("Error", "Error writing CD, cancelling")
    Send ("{ENTER}")
    EndIf
    $sTest4 = WinExists ("Error", "Error writing CD, cancelling")
    If $sTest4 = 1 Then     
        MsgBox (0, "User Intervention Required", "Please click OK in the Impax ERROR dialogue box" & @CRLF & " " & @CRLF & "Then click OK here to proceed")
        EndIf

    
        
    
        FileDelete ("c:\burn\autorun.inf")
        
        DirRemove ("c:\burn\info" ,1)
        DirRemove ("c:\burn\programs")
  
    
    $sPwdfile = @ScriptDir&"\config\CurrentPwd.txt"
    $sPwd = FileRead($sPwdfile)
    ProcessClose ("progress.exe")
    FileCopy (@ScriptDir & "\cd_encryption\*.*", "c:\cd_temp\", 9)
;MsgBox (0, "pause", "paused pre-burn")

    
    RunWait (@ScriptDir & '\7Za.exe a -mx1 -mhe=on -p"'&$sPwd&'" -t7z c:\cd_temp\encrypted.7z c:\burn\*') 
    
;MsgBox(4096, "pause", "Paused")
  $sCreated = IniRead(@ScriptDir & "\config\encryption.ini", "CreatedOn", "Machine","Agfa")
  $handleHelp = FileOpen ("c:\cd_temp\STARThelp.txt", 1)
        FileWrite ("c:\cd_temp\STARThelp.txt", $sCreated & @TAB & @MDAY & "/" & @MON & "/" & @YEAR & "   " & @HOUR & ":" & @MIN & ":" & @SEC)
    FileClose ($handleHelp)
    
    $sDriveType = DriveGetType ($sCDdrive & ":")
    $sDriveReady = DriveStatus($sCDdrive & ":")
    
  
 Select
        Case $sDriveType = "CDROM";and $sDriveReady = "READY"  
 
 ;RunWait (@ScriptDir & "\createCD.exe -r:" & $sCDdrive & " -l -eject C:\cd_temp\*.*")
  $sCDBuildCommand = @ScriptDir & "\imgburn.exe /MODE BUILD /SRC " & @ScriptDir & "\encrypt.ibb /DEST " & $sCDdrive & ": /start /close /verify no /rootfolder yes /eject yes /NOIMAGEDETAILS yes /PORTABLE yes"
    RunWait ($sCDBuildCommand)
 ;MsgBox(64, "CD ready", "CD burning completed", 3)
  FileDelete (@ScriptDir & "\7Za.exe")
    FileDelete (@ScriptDir & "\encrypt.ibb")
  FileDelete (@ScriptDir & "\CreateCD.exe")
  DirRemove ("c:\burn", 1)
  DirRemove ("c:\cd_temp", 1)
  DirCreate ("c:\cd_temp")
  
    Case $sDriveType <> "CDROM" 
        MsgBox(0, "Drive error", $sCDdrive & ": is not a CD Drive"  & @CRLF & "Please change the configuration file setting" & @CRLF & "for [CDdriveLetter]"  & @CRLF & " " & @CRLF & "Press F2 to open config file" & @CRLF & "then restart this prgram")
    
    EndSelect
    $sTest2 = 0
WEnd;CLOSEClicked
DirRemove($sAgfaCDfolder, 1);removes YYYYMMDD... folder
DirRemove ($sSourcePath, 1)
    DirCreate ($sSourcePath);empties burn folder


ProcessClose ("progress.exe")
EndFunc

regards,

William

Share this post


Link to post
Share on other sites
Jos

This fileinstall will give you errors because @scriptdir is not allowed in the first parameter:

FileInstall(@ScriptDir & "dir.bat", $sDirectoryList1, 1)

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
saywell

This fileinstall will give you errors because @scriptdir is not allowed in the first parameter:

FileInstall(@ScriptDir & "dir.bat", $sDirectoryList1, 1)

Thanks, Jos.

I did know that, but I'd been concentrating on the earlier fileinstalls [that the error message referenced] and hadn't spotted that one.

So if there is any error in a fileinstall command anywhere in the script, it obviously throws up an error message relating to the first one in the script? it's a bit counterintuitive - but I have learned something for next time!

Thanks again.

William

Share this post


Link to post
Share on other sites
Jos

Indeed looks like it just shows the first FileInstall() when a subsequent one is in error.

Didn't know that either.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Jos

Indeed looks like it just shows the first FileInstall() when a subsequent one is in error.

Didn't know that either.

Jos

Looks like it always displays the first parameter of the previous Fileinstall() when that error is displayed. Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
saywell

Looks like it always displays the first parameter of the previous Fileinstall() when that error is displayed.

That's well worth knowing, if only to stop others falling into the same trap as me when debugging - ie not going any further than the apparent source of the error.

William

Share this post


Link to post
Share on other sites
saywell

Another thought - I wonder why Scite doesn't pick up this error when doing its code checks?

It could look for special character (eg $, @ etc) that are not in ""s and precede the first comma.

W.

Share this post


Link to post
Share on other sites
Jos

Another thought - I wonder why Scite doesn't pick up this error when doing its code checks?

It could look for special character (eg $, @ etc) that are not in ""s and precede the first comma.

W.

I guess you mean AU3CHECK which is run by AutoIt3Wrapper everytime you hit F5 or F7.

Not sure how easy it is to add that to it. I try to stay away from that program unless there is a real but as my brain already starts hurting by the thought of having to open it. :)

It is actually very slick and using Flex and Yacc but for some reason its not my "cup of tea".

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Valik

Jos, I don't imagine it to be too hard from the standpoint that you can just copy the UDF_P concept and tweak it. I don't think it's worth the effort, though. Though there isn't a ticket for it (oops) I still plan to rewrite FileInstall() from scratch to eliminate the issue completely by providing a better distinction between compile-time and run-time code. This will require a whole other set of Au3Check changes.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×