Jump to content

Everything looks correct to me, But according to Scite there is problems


Recommended Posts

I require some help.

When i try to do a test compile, scite freaks out with 

 

Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\Bob\Desktop\Wim-Deployment\Wim-Deployment-1.5.au3
"C:\Users\Tech 3\Desktop\Wim-Deployment\Wim-Deployment-1.5.au3"(106,6) : error: missing EndSwitch.
                    Else
                    ^
"C:\Users\Bob\Desktop\Wim-Deployment\Wim-Deployment-1.5.au3"(86,15) : REF: missing EndSwitch.
        Switch $nMsg
        ~~~~~~~~~~~~^
"C:\Users\Bob\Desktop\Wim-Deployment\Wim-Deployment-1.5.au3"(106,6) : error: missing Wend.
                    Else
                    ^
"C:\Users\Bob\Desktop\Wim-Deployment\Wim-Deployment-1.5.au3"(84,2) : REF: missing Wend.
    While
    ^
"C:\Users\Bob\Desktop\Wim-Deployment\Wim-Deployment-1.5.au3"(106,11) : error: syntax error
                    Else MsgBox
                    ~~~~~^
"C:\Users\Bob\Desktop\Wim-Deployment\Wim-Deployment-1.5.au3"(106,11) : error: Statement cannot be just an expression.
                    Else MsgBox
                    ~~~~~^
"C:\Users\Bob\Desktop\Wim-Deployment\Wim-Deployment-1.5.au3"(110,3) : error: syntax error
        EndSwitch
        ^
"C:\Users\Bob\Desktop\Wim-Deployment\Wim-Deployment-1.5.au3"(110,3) : error: Statement cannot be just an expression.
        EndSwitch
        ^
"C:\Users\Bob\Desktop\Wim-Deployment\Wim-Deployment-1.5.au3"(111,2) : error: Statement cannot be just an expression.
    WEnd
    ^
"C:\Users\Bob\Desktop\Wim-Deployment\Wim-Deployment-1.5.au3"(112,1) : error: Statement cannot be just an expression.
Else
^
"C:\Users\Bob\Desktop\Wim-Deployment\Wim-Deployment-1.5.au3"(115,1) : error: syntax error
EndIf
^
"C:\Users\Bob\Desktop\Wim-Deployment\Wim-Deployment-1.5.au3"(115,1) : error: Statement cannot be just an expression.
EndIf
^
C:\Users\Bob\Desktop\Wim-Deployment\Wim-Deployment-1.5.au3 - 10 error(s), 0 warning(s)
!>09:02:36 AU3Check ended. Press F4 to jump to next error.rc:2
+>09:02:36 AutoIt3Wrapper Finished.
>Exit code: 2    Time: 1.744

 

This is my code any help would be appreciated, most likely i'm missing something small 

 

#NoTrayIcon
#RequireAdmin

#Region ; Includes
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPIFiles.au3>
#include <Array.au3>
#include <File.au3>
#include <String.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#EndRegion

If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client\", "TargetVersion") = "4.0.0" Then
    DirCreate("C:\Temp\")
    DirCreate("C:\Temp\Logs\")
    ;FileInstall("V:\temp\ImagingCommonManagedLib.dll","C:\Temp\ImagingCommonManagedLib.dll")
    FileInstall("C:\temp\RadsImageX.exe", "C:\Temp\RadsImageX.exe")
    FileInstall("C:\temp\SecureWimNet.dll", "C:\Temp\SecureWimNet.dll")
    FileInstall("C:\temp\wimgapi.dll", "C:\Temp\wimgapi.dll")

    #Region Varibles
    $Main = GUICreate("WIM Deployment Tool v1.5", 616, 439, 192, 124)
    $Start = GUICtrlCreateButton("Start", 488, 376, 105, 41)
    $Exit = GUICtrlCreateButton("Exit", 16, 376, 105, 41)
    $Browse = GUICtrlCreateButton("Browse", 488, 176, 105, 41)
    $Path = GUICtrlCreateInput("Path", 232, 192, 201, 21)
    $HDD = GUICtrlCreateCombo("", 232, 288, 201, 19)
    GUICtrlSetData(-1, "")
    $LabelBrowse = GUICtrlCreateLabel("Path of Image File *.wim", 96, 192, 117, 17)
    $SelectHDD = GUICtrlCreateLabel("Select Destination Dive", 96, 288, 115, 17)
    GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)
    Local $aData, $aDrive = DriveGetDrive('FIXED')
    Local $aList[10]
    Local $temp = "C:\temp\Logs\"
    #EndRegion ### END Koda GUI section ###

#Region ; Drive Array
    For $i = 0 To UBound($aDrive) - 1
        $aList[$i] = ''
    Next
    If IsArray($aDrive) Then
        For $i = 1 To $aDrive[0]
            $aData = _WinAPI_GetDriveNumber($aDrive[$i])
            If IsArray($aData) Then
                $aList[$aData[1]] &= StringUpper($aDrive[$i]) & ' '
            EndIf
        Next
    EndIf
    For $i = 0 To UBound($aDrive) - 1
        If $aList[$i] Then
            GUICtrlSetData($HDD, "" & $i & " => " & $aList[$i])
        EndIf
    Next
#EndRegion

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $Exit
                Exit
            Case $Browse
                $File2open = FileOpenDialog("Please Select .wim to deploy", @WindowsDir & "\", "Image (*.wim)") ;returns the file path
                GUICtrlSetData($Path, $File2open)   ;set input data
            Case $Start
                $hddnumbers = GUICtrlRead($HDD, 0)
                $hddnumber = StringRegExpReplace($hddnumbers, "\D", "")
                Run(@ComSpec & " /c " & 'C:\temp\RadsimageX.exe' & " /apply " & '"' & $File2open & '"' & " factory " & $hddnumber, "", @SW_HIDE)
 ; Move log files
                ProcessWaitClose("RadsimageX.exe")
                    Sleep (3000)
Local $logmove = FileFindFirstFile($Path & "RadsImageX*.log")
                FileClose($logmove)
                FileMove($logmove, $temp & "RadsimagexLastUsed.log")
                Sleep (2000)

 ; Read log file with Success or Fail
                    If StringRegExp(FileRead("C:\temp\Logs\RadsimagexLastUsed.log"),"CApplyImageThread::Run(): Apply operation succeeded",0,0) Then MsgBox($MB_OK,"Win Deployment","Image was deployed successfuly",0)
                    Else MsgBox($MB_ICONERROR,"Win Deployment","Failure, You are a failure at life, you need to grab a new drive and try again",0)
                    EndIf

                Exit
        EndSwitch
    WEnd
Else
    MsgBox(1, ".net Framework Error", ".net 4.0 appears not to be installed. Program will not run.")
    Exit
EndIf

 

Link to comment
Share on other sites

Your If...Then..Else is the issue. Change it to look like this --

If StringRegExp(FileRead("C:\temp\Logs\RadsimagexLastUsed.log"),"CApplyImageThread::Run(): Apply operation succeeded",0,0) Then
                        MsgBox($MB_OK,"Win Deployment","Image was deployed successfuly",0)
                    Else
                        MsgBox($MB_ICONERROR,"Win Deployment","Failure, You are a failure at life, you need to grab a new drive and try again",0)
                    EndIf

 

Link to comment
Share on other sites

15 minutes ago, Danp2 said:

Your If...Then..Else is the issue. Change it to look like this --

If StringRegExp(FileRead("C:\temp\Logs\RadsimagexLastUsed.log"),"CApplyImageThread::Run(): Apply operation succeeded",0,0) Then
                        MsgBox($MB_OK,"Win Deployment","Image was deployed successfuly",0)
                    Else
                        MsgBox($MB_ICONERROR,"Win Deployment","Failure, You are a failure at life, you need to grab a new drive and try again",0)
                    EndIf

 

This section is still not working, the script compiles but it doesn't matter if it finds the string or not it still returns the failure message. I am including a copy of the good log and a bad log.

RadsImageX.exe_6848.log RadsImageX.exe_8808-bad.log

Link to comment
Share on other sites

StringRegExp returns an array (or not). You must check @error instead, as the help says. BTW the offset should be 1, not 0.

Then StringInStr is simpler and faster in your use case as others said.

Local $s = FileRead("RadsImageX.exe_6848.log")

StringRegExp($s, "CApplyImageThread::Run(): Apply operation succeeded")
If @error Then
    MsgBox($MB_ICONERROR,"Win Deployment 1","Failure, You are a failure at life, you need to grab a new drive and try again",0)
Else
    MsgBox($MB_OK,"Win Deployment 1","Image was deployed successfuly",0)
EndIf

If StringInStr($s, "CApplyImageThread::Run(): Apply operation succeeded") = 0 Then
    MsgBox($MB_ICONERROR,"Win Deployment 2","Failure, You are a failure at life, you need to grab a new drive and try again",0)
Else
    MsgBox($MB_OK,"Win Deployment 2","Image was deployed successfuly",0)
EndIf

 

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Good.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Apparently I am still having a small issue. 

 

Local $logmove = FileFindFirstFile($Path & "RadsImageX*.log")
                FileClose($logmove)
                FileMove($logmove, $temp & "RadsimagexLastUsed.log")

the $path I get it to read the total file path but I need to truncate some of the information so that I only receive the directory path.

 

Eg. If the file that I am choosing is located in C:\test\wim\test.wim then the variable for $path is "C:\test\wim\test.wim", However I need to exclude the File name so I need the variable to be "C:\test\wim\"

 

Any help would be appreciative

 

Link to comment
Share on other sites

_PathSplit() or (simpler):

Local $sFullPath = "C:\test\something else\wim\test.wim"
Local $sFileFolder = StringRegExpReplace($sFullPath, "(.*\\)([^\\]*)", "$1")
ConsoleWrite($sFileFolder & @LF)

 

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...