Jump to content
Sign in to follow this  
maxrealqnx

How to disable Autoit Error Message window ?

Recommended Posts

maxrealqnx

Hi my friends ;)

This code works great when given the right path. If given a wrong way, it gives error message. If given the wrong path, no error message appears.

If this bit of code can be managed, error message does not appear.

If $SERACHFOLDER = "" Then Exit

But if you selected the wrong path, an error occurs in the code. How can I get rid of this problem. Thank you for your respond :)

If $SEARCH <> -1 Then

Example : zPeIMG.exe c:\drivers d:\windows @SW_HIDE

zPeIMG.au3

#include <file.au3>
#NoTrayIcon
;
If $CmdLine[0] = 0 Then
    MsgBox (64, "Information", "*.Inf Searcher v1.0 by JFX & Max_Real Qnx")     
Exit
EndIf
;
#Region
#AutoIt3Wrapper_Outfile_Type=a3x
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseUpx=n
#EndRegion
Dim $SERACHFOLDER, $TARGETWIN, $PEIMG, $SHOWFLAG, $Q1, $szDrive, $szDir, $szFName, $szExt, $Dsize
Opt("MustDeclareVars", 1)
If $CMDLINE[0] < 2 Then Exit
$PEIMG = @ScriptDir & "\peimg.exe"
$SERACHFOLDER = $CMDLINE[1]
$TARGETWIN = $CMDLINE[2]
$TARGETWIN = FileGetShortName($TARGETWIN)
$SHOWFLAG = @SW_SHOW
If $CMDLINE[0] = 3 Then
    If $CMDLINE[3] = "@SW_SHOW" Then
        $SHOWFLAG = @SW_SHOW
    ElseIf $CMDLINE[3] = "@SW_HIDE" Then
        $SHOWFLAG = @SW_HIDE
    EndIf
EndIf
Global $STACK_MAX = 1
Global $STACK[$STACK_MAX]
$STACK[0] = 0

Func _PUSH($VAR)
    If $STACK[0] > $STACK_MAX - 2 Then
        $STACK_MAX *= 2
        ReDim $STACK[$STACK_MAX]
    EndIf
    $STACK[0] += 1
    $STACK[$STACK[0]] = $VAR
    Return 1
EndFunc


Func _POP()
    If $STACK[0] > 0 Then
        $STACK[0] -= 1
        Return $STACK[$STACK[0] + 1]
    Else
        SetError(1)
    EndIf
    Return 0
EndFunc

Global $RESULT = _SEARCH($SERACHFOLDER, "*.inf", True, -1)
For $X = 1 To $RESULT[0]
    $Q1 = FileGetShortName($RESULT[$X])
    ShellExecuteWait($PEIMG, "/inf=" & Chr(34) & $Q1 & Chr(34) & " " & $TARGETWIN, @ScriptDir, "", $SHOWFLAG)
    _PathSplit($RESULT[$X], $szDrive, $szDir, $szFName, $szExt)
    ;MsgBox (0 ,"", $TARGETWIN)
    DirCreate ($TARGETWIN & "\System32\drivers")
    If FileExists ($szDrive & $szDir & "*.sys") Then FileCopy ($szDrive & $szDir & "*.sys", $TARGETWIN & "\system32\drivers")
    If FileExists ($szDrive & $szDir & "*.kmd") Then FileCopy ($szDrive & $szDir & "*.kmd", $TARGETWIN & "\system32\drivers")
    If FileExists ($szDrive & $szDir & "*.dll") Then FileCopy ($szDrive & $szDir & "*.dll", $TARGETWIN & "\system32")
    If FileExists ($szDrive & $szDir & "*.exe") Then FileCopy ($szDrive & $szDir & "*.exe", $TARGETWIN & "\system32")
    If FileExists ($szDrive & $szDir & "*.pb") Then FileCopy ($szDrive & $szDir & "*.pb", $TARGETWIN & "\system32")
    If FileExists ($szDrive & $szDir & "*.xml") Then FileCopy ($szDrive & $szDir & "*.xml", $TARGETWIN & "\system32")
Next

Func _SEARCH($PATH, $FILTER, $DIRECTORIES = True, $DEPTH = -1)
    If $SERACHFOLDER = "" Then Exit
    ;$Dsize = DirGetSize($SERACHFOLDER)
    ;If $Dsize = "0" Then Exit
    If FileExists($PATH) Then
        If StringCompare(StringRight($PATH, 1), "\") <> 0 Then
            $PATH &= "\"
        EndIf
        Local $RESULT = ""
        Local $SEARCH, $FNAME, $ATTRIB
        Local $ARRAY[2], $TEMP[2]
        $ARRAY[0] = $PATH
        $ARRAY[1] = $DEPTH
        _PUSH($ARRAY)
        While 1
            $ARRAY = _POP()
            If @error == 1 Then
                ExitLoop
            EndIf
            $SEARCH = FileFindFirstFile($ARRAY[0] & $FILTER)
            If $SEARCH <> -1 Then
                While 1
                    $FNAME = FileFindNextFile($SEARCH)
                    If @error == 1 Then
                        ExitLoop
                    EndIf
                    If @extended == 1 Then
                        If Not $DIRECTORIES Then
                            ContinueLoop
                        Else
                            $FNAME &= "\"
                        EndIf
                    EndIf
                    $RESULT &= $ARRAY[0] & $FNAME & "|"
                WEnd
                FileClose($SEARCH)
            EndIf
            If $ARRAY[1] <> 0 Then
                $SEARCH = FileFindFirstFile($ARRAY[0] & "*")
                While 1
                    $FNAME = FileFindNextFile($SEARCH)
                    If @error == 1 Then
                        ExitLoop
                    EndIf
                    $TEMP[0] = $ARRAY[0] & $FNAME & "\"
                    $TEMP[1] = $ARRAY[1] - 1
                    _PUSH($TEMP)
                WEnd
                FileClose($SEARCH)
            EndIf
        WEnd
        If StringCompare(StringRight($RESULT, 1), "|") == 0 Then
            $RESULT = StringTrimRight($RESULT, 1)
            $RESULT = StringSplit($RESULT, "|")
        Else
            $RESULT = 0
            SetError(2, 0, 0)
        EndIf
        Return $RESULT
    Else
        SetError(1, 0, 0)
    EndIf
EndFunc

post-36686-12818252664942_thumb.png

Edited by maxrealqnx

Share this post


Link to post
Share on other sites
JFX

Hi Max,

my mistake ;)

after

Global $RESULT = _SEARCH($SERACHFOLDER, "*.inf", True, -1)

add this:

IF Not IsArray($RESULT) Then Exit(1); No inf file found in given folder

For your copying driver files, i'm not sure if it is necessary.

Share this post


Link to post
Share on other sites
maxrealqnx

Hi Max,

my mistake :P

after

Global $RESULT = _SEARCH($SERACHFOLDER, "*.inf", True, -1)

add this:

IF Not IsArray($RESULT) Then Exit(1); No inf file found in given folder

For your copying driver files, i'm not sure if it is necessary.

Hi my friend JFX :)

I'm thank you very much for you very very nice tips ;)

If the files (*.sys) does not exist in the destination (%target_sys%) folder, some Inf files when install error occurs with pnputil.exe . o:)

God bless you ;)

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  

×