Jump to content

The program is freezes when the focus changes


Recommended Posts

hi

I needed to scan the some files by antivirus via commandline and wrote it with "autoit"
But my problem is that when I run the antivirus cli with autoit (using the run command to get the output) if i change focus (cli focus) to another app or ... , "autoit" process and the antivirus cli process and window freezed. (Actully after finish scan, cli and process closed automaticly, But something will cause it to freeze)
My only solution to solve this problem is to write a loop to activate the focus of the cli window, but this focus makes working with Windows a little difficult (due to the focus changing to another program and losing the focus of the programs i working with them.)
I need some help
Thanks

 

Process freeze if change focus! and unfreezed if click in cli !

While 1
    IF Not ProcessExists($Max_Scanner_Process) Then
        $sCommand = "C:\Program Files\Max Secure Anti Virus Plus\MaxCMDScanner.exe /C /V /CM /E /DRIVES:" & '"' & $aCmdLine[2] & '"'
        $iPID = Run($sCommand, "C:\Program Files\Max Secure Anti Virus Plus\", @SW_SHOW, $STDERR_MERGED)
        ProcessWaitClose($iPID)
        $sOutput = StdoutRead($iPID)
        ConsoleWrite($sOutput)
        ExitLoop
    EndIf
WEnd

 

 

Losing focus on programs I'm working with

While 1
    IF Not ProcessExists($Max_Scanner_Process) Then
        $sCommand = "C:\Program Files\Max Secure Anti Virus Plus\MaxCMDScanner.exe /C /V /CM /E /DRIVES:" & '"' & $aCmdLine[2] & '"'
        $iPID = Run($sCommand, "C:\Program Files\Max Secure Anti Virus Plus\", @SW_SHOW, $STDERR_MERGED)
        While 1
            IF ProcessExists($iPID) Then
                Local $proc_hWnd = _GetPIDWindows($iPID)
                IF $proc_hWnd Then
                    Sleep(1000)
                    WinActivate($proc_hWnd)
                EndIf
            Else
                ExitLoop
            EndIf
        WEnd
        $sOutput = StdoutRead($iPID)
        ConsoleWrite($sOutput)
        ExitLoop
    EndIf
WEnd

 

 

 

Link to comment
Share on other sites

I don't understand the question very well.
But I tried with below code and it get result after scan done:

#RequireAdmin
#include <WinAPIShPath.au3>
Global $MaxAV_EXEdir = @HomeDrive & "\Program Files\Max Secure Anti Virus Plus\"
Global $MaxAV_EXE = "MaxCMDScanner.exe"
Global $MaxAV_Option = "/C /V /CM /E /DRIVES:"
Global $aCmdLineRaw = @Compiled ? StringReplace($CmdLineRaw, '/ErrorStdOut "' & @ScriptFullPath & '"', "") : @WindowsDir & "\EXPLORER.EXE"  ; TEST FILE
;ConsoleWrite($aCmdLineRaw & @CRLF)
Global $aCmdLine = _WinAPI_CommandLineToArgv($aCmdLineRaw)
If IsArray($aCmdLine) And $aCmdLine[0] > 0 Then
    For $i = 1 To $aCmdLine[0]
        Local $icout = 99
        If WinExists("MaxCMDScanner") Then
            While WinExists("MaxCMDScanner")
                ControlClick("MaxCMDScanner", "", '[CLASS:Button; INSTANCE:1]')
                ControlClick("MaxCMDScanner", "Command Line Scanner  is already Running", '[CLASS:Button; INSTANCE:1]')
                WinClose("MaxCMDScanner")
                $icout -= 1
                If $icout < 1 Then ExitLoop
            WEnd
        EndIf
        If ProcessExists($MaxAV_EXE) Then
            ConsoleWrite("! Error: MaxCMDScanner is busy with another task, please come back later!" & @CRLF)
            MsgBox(16, "Max Secure Anti Virus Plus", "Error: MaxCMDScanner is busy with another task, please come back later!")
        Else
            Local $sCommand = '"' & $MaxAV_EXEdir & $MaxAV_EXE & '" ' & $MaxAV_Option & '"' & $aCmdLine[$i] & '"'
            Local $output = _RunCmd_GetOutput($sCommand, $MaxAV_EXEdir)
            MsgBox(64, "Max CMD Scanner: " & $aCmdLine[$i], $output)
        EndIf
    Next
    Exit
EndIf
MsgBox(16, "Max CMD Scanner!", "No command or file input! => EXIT" & @CRLF & "Usage: " & @ScriptName & " <filePath>")
Exit

Func _RunCmd_GetOutput($sCommand, $WorkingDir = @WorkingDir)
    ConsoleWrite("+Execute: " & $sCommand & @CRLF)
    Local $sOutput = '', $iPID = Run($sCommand, $WorkingDir, @SW_SHOW, 0x6)
    Do
        $sOutput &= StdoutRead($iPID)
    Until @error
    Do
        $sOutput &= StderrRead($iPID)
    Until @error
    ConsoleWrite($sOutput & @CRLF)
    Return $sOutput
EndFunc   ;==>_RunCmd_GetOutput

PS: This antivirus is pretty bad, you should consider switching to Avast

Regards,
 

Link to comment
Share on other sites

thanks Trong

i try your code and that's work successfully

But I see the problem I had in your code
For better understanding, please run your own code, now change the focus immediately after the black screen opens and starts scanning the file (before displaying the scan result in the message box).
It's done, no matter how long you wait, the scan will not finish! This is my problem and I don't know why it happens and how to fix it.

Link to comment
Share on other sites

8 minutes ago, r2du-soft said:

thanks Trong

i try your code and that's work successfully

But I see the problem I had in your code
For better understanding, please run your own code, now change the focus immediately after the black screen opens and starts scanning the file (before displaying the scan result in the message box).
It's done, no matter how long you wait, the scan will not finish! This is my problem and I don't know why it happens and how to fix it.

 

also in method 2 I want if the scanner is scanning, wait until I can do a new scan after the current scan is finished ...

method 1 :

;-----------------------------------------------------
;#Compiler options
#RequireAdmin
#NoTrayIcon
;-----------------------------------------------------

;-----------------------------------------------------
;#pragma options
#pragma compile(Out, "MaxCLIScanner.exe")
#pragma compile(ExecLevel, requireAdministrator)
;-----------------------------------------------------

;-----------------------------------------------------
;#includes
#include-once
#include <Process.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <AutoItConstants.au3>
#include <Array.au3>
#include <WinAPIShPath.au3>
;-----------------------------------------------------

;-----------------------------------------------------
;#Variables
Local $aCmdLine = _WinAPI_CommandLineToArgv($CmdLineRaw)
Local $ext
Local $iPID
Local $sOutput
Local $name
Local $amount
Local $aProcessList
;-----------------------------------------------------


_Force_Run_As_Administrator()
_Prevent_Run_Duplicate_Process()
Scan_file()

Func Scan_file()
        IF ($aCmdLine[0] == 2) Then
            IF ($aCmdLine[1] == "/scan") Then
                IF FileExists($aCmdLine[2]) Then
                    $iPID = Run('"C:\Program Files\Max Secure Anti Virus Plus\MaxCMDScanner.exe" /C /V /CM /E /DRIVES:' & '"' & $aCmdLine[2] & '"', "C:\Program Files\Max Secure Anti Virus Plus\", @SW_SHOW, $STDOUT_CHILD)
                    ProcessWaitClose($iPID)
                    $sOutput = StdoutRead($iPID)
                    ConsoleWrite($sOutput)
                Else
                    ConsoleWrite("can not find file:" & $aCmdLine[2])
                    Exit
                EndIf
            Else
                ConsoleWrite('just can send "/scan" switch')
                Exit
            EndIf
        Else
            ConsoleWrite('command sample: "C:\MaxCLIScanner.exe" /scan "C:\eicar.com"')
            Exit
        EndIf
EndFunc

Func _Force_Run_As_Administrator()
        ;--------------------------------
        ;Run Ad Admin
        IF Not IsAdmin() Then
            ShellExecute(@AutoItExe, "", "", "runas")
            ProcessClose(@AutoItPID)
            Exit
        Else
            ;Is Administrator
        EndIf
        ;--------------------------------
EndFunc


Func _Prevent_Run_Duplicate_Process()
        ;--------------------------------
        ;Close IF Exist Another Process With This Name
        ;Prevent Run Duplicate Process
        $name = @ScriptName
        $amount = Processlist($name)
        While $amount[0][0] > 1
            ConsoleWrite("cli in use by another scan.")
            ProcessClose(@AutoItPID)
            ;$amount = Processlist($name)
        WEnd
        ;--------------------------------
EndFunc

 

method 2:

;-----------------------------------------------------
;#Compiler options
#RequireAdmin
#NoTrayIcon
;-----------------------------------------------------

;-----------------------------------------------------
;#pragma options
#pragma compile(Out, "MaxCLIScanner.exe")
#pragma compile(ExecLevel, requireAdministrator)
;-----------------------------------------------------

;-----------------------------------------------------
;#includes
;#include-once
#include <Process.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <AutoItConstants.au3>
#include <Array.au3>
#include <WinAPIShPath.au3>
#include <WinAPIConv.au3>
#include <Constants.au3>
;-----------------------------------------------------

;-----------------------------------------------------
Opt("MustDeclareVars", 1)
;-----------------------------------------------------

;-----------------------------------------------------
;#Variables
Local $aCmdLine = _WinAPI_CommandLineToArgv($CmdLineRaw)
Local $Max_Scanner_Process = "MaxCMDScanner.exe"
Local $ext
Local $iPID
Local $sOutput
Local $name
Local $amount
Local $aProcessList
Local $sCommand
;-----------------------------------------------------


_Force_Run_As_Administrator()
Scan_file()

Func Scan_file()
        IF ($aCmdLine[0] == 2) Then
            IF ($aCmdLine[1] == "/scan") Then 
                IF FileExists($aCmdLine[2]) Then
                    While 1
                        Sleep(100)
                        IF Not ProcessExists($Max_Scanner_Process) Then
                            $sCommand = "C:\Program Files\Max Secure Anti Virus Plus\MaxCMDScanner.exe /C /V /CM /E /DRIVES:" & '"' & $aCmdLine[2] & '"'
                            $iPID = Run($sCommand, "C:\Program Files\Max Secure Anti Virus Plus\", @SW_HIDE, $STDERR_MERGED)
                            ;ProcessWaitClose($iPID)
                            While 1
                                IF ProcessExists($iPID) Then
                                    Local $proc_hWnd = _GetPIDWindows($iPID)
                                    IF $proc_hWnd Then
                                        ;WinSetState($proc_hWnd, "", @SW_HIDE)
                                        Sleep(1000)
                                        WinActivate($proc_hWnd)
                                    EndIf
                                Else
                                    ExitLoop
                                EndIf
                            WEnd
                            $sOutput = StdoutRead($iPID)
                            ConsoleWrite($sOutput)
                            ExitLoop
                        EndIf
                    WEnd
                    Exit
                Else
                    ConsoleWrite("can not find file:" & $aCmdLine[2])
                    Exit
                EndIf
            Else
                ConsoleWrite('just can send "/scan" switch')
                Exit
            EndIf
        Else
            ConsoleWrite('command sample: "C:\MaxCLIScanner.exe" /scan "C:\eicar.com"')
            Exit
        EndIf
EndFunc

Func _Force_Run_As_Administrator()
        ;--------------------------------
        ;Run Ad Admin
        IF Not IsAdmin() Then
            ShellExecute(@AutoItExe, "", "", "runas")
            ProcessClose(@AutoItPID)
            Exit
        Else
            ;Is Administrator
        EndIf
        ;--------------------------------
EndFunc

Func _Kill_Proc($Proc_name)
        $aProcessList = ProcessList($Proc_name)
        ;_ArrayDisplay($aProcessList, "display array process")
        For $i = 1 To $aProcessList[0][0]
            IF NOT ($aProcessList[$i][1] == @AutoItPID) Then
                _RunDOS("taskkill /f /im " & $Proc_name & " /t")
                _RunDOS("taskkill /F /PID " & $aProcessList[$i][1] & " /T")
                ProcessClose($aProcessList[$i][1])
            EndIf
        Next
EndFunc

func _GetPIDWindows($PID)
    Local $WinList = WinList()
    for $i = 1 to $WinList[0][0]
        if WinGetProcess($WinList[$i][1]) = $PID then 
            Return $WinList[$i][1]
        EndIf
    Next
    Return 0
EndFunc

 

Edited by r2du-soft
Link to comment
Share on other sites

The problem is in MaxCMDScanner.exe it won't quit if you don't activate the scan window! But cannot use AutoIT's function to activate that window.

And you also can't close antivirus processes with taskkill or processClose because it's protected by drivers!
I am quite annoyed and annoyed with this antivirus so I spent three hours researching and you can refer to the code:

;-----------------------------------------------------
;#Compiler options
#RequireAdmin
#NoTrayIcon
;-----------------------------------------------------

;-----------------------------------------------------
;#pragma options
#pragma compile(Out, "MaxCLIScanner.exe")
#pragma compile(ExecLevel, requireAdministrator)
#pragma compile(Console, true)
#pragma compile(LegalTrademarks, 'Dao Van Trong - TRONG.LIVE')
;-----------------------------------------------------

;-----------------------------------------------------
;#includes
#include <Process.au3>
#include <WinAPIProc.au3>
#include <WinAPIShPath.au3>
;-----------------------------------------------------

;-----------------------------------------------------
Opt("MustDeclareVars", 1)
;-----------------------------------------------------

;-----------------------------------------------------
;#Variables
;~ Global $aCmdLineRaw = @Compiled ? $CmdLineRaw : StringReplace($CmdLineRaw, '/ErrorStdOut "' & @ScriptFullPath & '"', "") & ' "' & @ScriptFullPath & '"' ; ;TEST
Global $aCmdLineRaw = @Compiled ? $CmdLineRaw : StringReplace($CmdLineRaw, '/ErrorStdOut "' & @ScriptFullPath & '"', "")
Global $aCmdLine = _WinAPI_CommandLineToArgv($aCmdLineRaw)
Global $sPath_MaxCMDScanner = @HomeDrive & "\Program Files\Max Secure Anti Virus Plus"
Global $sProcess_MaxCMDScanner = "MaxCMDScanner.exe"
Global $sMaxCMDScanner = $sPath_MaxCMDScanner & "\" & $sProcess_MaxCMDScanner
Global $sOption_MaxCMDScanner = "/C /V /CM /E /DRIVES:"
;-----------------------------------------------------
If Not FileExists($sMaxCMDScanner) Then
    ConsoleWrite('! /!\ ERROR: MaxCMDScanner.exe" does not exist, please review the path or install "Max Secure Anti Virus Plus" !' & @CRLF & @CRLF)
    MsgBox(16, "/!\ MaxCLIScanner Error !", '"MaxCMDScanner.exe" does not exist, please review the path or install "Max Secure Anti Virus Plus" !', 5)
    Exit
EndIf

_Main()

Func _Main()
    If Not IsArray($aCmdLine) Or ($aCmdLine[0] < 1) Then
        ConsoleWrite("! No command or file input! " & @CRLF & "- Usage: " & @ScriptName & " <filePath_1>  <filePath_2> ...  <filePath_n> " & @CRLF & @CRLF)
        MsgBox(48, "/!\ MaxCLIScanner Error !", "! No command or file input! " & @CRLF & "- Usage: " & @ScriptName & " <filePath_1> ... <filePath_n> " & @CRLF & @CRLF, 30)
        Return SetError(1, 0, 0)
    EndIf
    For $i = 1 To $aCmdLine[0]
        _MaxScan($aCmdLine[$i])
    Next
EndFunc   ;==>_Main

Func _MaxScan($sFilePath)
    _TryClosingAnotherTask()
    If _Is_AnotherTaskIsAlreadyRunning() Then
        ConsoleWrite("! Error: MaxCLIScanner is busy with another task, please waiting..." & @CRLF)
        ToolTip("MaxCLIScannerr: Waiting for another process to finish...", 1, 1)
    EndIf
    While _Is_AnotherTaskIsAlreadyRunning()
        Sleep(100)
    WEnd
    ToolTip("MaxCLIScanner - Scanning: " & $sFilePath & "  - Please wait....", 1, 1)
    Local $sCommand = '"' & $sMaxCMDScanner & '" ' & $sOption_MaxCMDScanner & '"' & $sFilePath & '"'
    Local $sOutput = _RunWait($sCommand, $sPath_MaxCMDScanner)
    ;Processing output results here!
    If StringInStr($sOutput, "No Spyware Found") Then
        ToolTip("MaxCLIScanner - Scan done > No Spyware Found in: " & $sFilePath & " !", 1, 1)
        MsgBox(64, "MaxCLIScanner - Scan done !", "> No Spyware Found in: " & $sFilePath, 30)
    Else
        ToolTip("MaxCLIScanner - Scan done - Result: " & $sOutput, 1, 1)
        MsgBox(16, "Max CMD Scanner: " & $sFilePath, $sOutput, 30)
    EndIf
    ToolTip("")
EndFunc   ;==>_MaxScan

Func _RunWait($sCommand, $WorkingDir = @WorkingDir)
    ConsoleWrite("+ Execute Command: " & $sCommand & @CRLF)
    ConsoleWrite("+ WorkingDir: " & $sCommand & @CRLF)
    Local $sOutput = '', $iPID = Run($sCommand, $WorkingDir, @SW_HIDE, 0x8)
    Do
        ;ToolTip($sOutput)
        If StringInStr($sOutput, 'Scan End') Or StringInStr($sOutput, 'slowing down scanning') Then _ClosingTask($iPID)
        $sOutput &= StdoutRead($iPID)
    Until @error
    Do
        ;ToolTip($sOutput)
        If StringInStr($sOutput, 'Scan End') Or StringInStr($sOutput, 'slowing down scanning') Then _ClosingTask($iPID)
        $sOutput &= StderrRead($iPID)
    Until @error
    ConsoleWrite(StringStripWS($sOutput, 7) & @CRLF)
    Return $sOutput
EndFunc   ;==>_RunWait

Func _Is_AnotherTaskIsAlreadyRunning()
    ;If (WinExists("MaxCMDScanner") Or ProcessExists($sProcess_MaxCMDScanner)) Then Return 1
    If ProcessExists($sProcess_MaxCMDScanner) Then Return 1
    Return 0
EndFunc   ;==>_Is_AnotherTaskIsAlreadyRunning

Func _ClosingTask($iPID = @AutoItPID)
    Local $a_children = _WinAPI_EnumChildProcess($iPID)
    If IsArray($a_children) Then
        If $a_children[0][0] > 0 Then
            For $i = 1 To $a_children[0][0]
                ;ConsoleWrite($a_children[$i][0] & @CRLF)
                ;ConsoleWrite($a_children[$i][1] & @CRLF)
                Local $sProcessName = _ProcessGetName($a_children[$i][0])
                If $sProcessName = 'conhost.exe' Then ProcessClose($a_children[$i][0])
            Next
        EndIf
    EndIf
    Local $a_children = _WinAPI_EnumChildProcess(ProcessExists($sProcess_MaxCMDScanner))
    If IsArray($a_children) Then
        If $a_children[0][0] > 0 Then
            For $i = 1 To $a_children[0][0]
                ;ConsoleWrite($a_children[$i][0] & @CRLF)
                ;ConsoleWrite($a_children[$i][1] & @CRLF)
                Local $sProcessName = _ProcessGetName($a_children[$i][0])
                If $sProcessName = 'conhost.exe' Then ProcessClose($a_children[$i][0])
            Next
        EndIf
    EndIf
    Local $a_children = _WinAPI_EnumChildProcess(@AutoItPID)
    If IsArray($a_children) Then
        If $a_children[0][0] > 0 Then
            For $i = 1 To $a_children[0][0]
                ;ConsoleWrite($a_children[$i][0] & @CRLF)
                ;ConsoleWrite($a_children[$i][1] & @CRLF)
                Local $sProcessName = _ProcessGetName($a_children[$i][0])
                If $sProcessName = 'conhost.exe' Then ProcessClose($a_children[$i][0])
            Next
        EndIf
    EndIf
EndFunc   ;==>_ClosingTask

Func _TryClosingAnotherTask()
    ;For $i = 1 To 100
    ;   ProcessClose("conhost.exe")
    ;Next
    Local $icout = 99
    If WinExists("MaxCMDScanner") Then
        While WinExists("MaxCMDScanner")
            ControlClick("MaxCMDScanner", "", '[CLASS:Button; INSTANCE:1]')
            ControlClick("MaxCMDScanner", "Command Line Scanner  is already Running", '[CLASS:Button; INSTANCE:1]')
            WinClose("MaxCMDScanner")
            $icout -= 1
            If $icout < 1 Then ExitLoop
        WEnd
    EndIf
    Local $icout = 99
    If WinExists($sMaxCMDScanner) Then
        While WinExists($sMaxCMDScanner)
            WinActive($sMaxCMDScanner)
            WinClose($sMaxCMDScanner)
            WinClose("MaxCMDScanner")
            $icout -= 1
            If $icout < 1 Then ExitLoop
        WEnd
    EndIf
EndFunc   ;==>_TryClosingAnotherTask

 

Regards,
 

Link to comment
Share on other sites

Thank you Trong  for the time you spent on me

I found the solution to the freezing problem

just can send enter to MaxCMDscanner.exe. By doing this, the focus will not be lost and the process will close automatically after the scan is finished.

ControlSend($proc_hWnd, "", "", "{ENTER}")

 

;-----------------------------------------------------
;#Compiler options
#RequireAdmin
#NoTrayIcon
;-----------------------------------------------------

;-----------------------------------------------------
;#pragma options
#pragma compile(Out, "MaxCLIScanner.exe")
#pragma compile(ExecLevel, requireAdministrator)
;#pragma compile(Console, true)
#pragma compile(FileDescription, "MaxCLIScanner")
#pragma compile(ProductName, 'MaxCLIScanner')
;-----------------------------------------------------

;-----------------------------------------------------
;#includes
;#include-once
#include <Process.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <AutoItConstants.au3>
#include <Array.au3>
#include <WinAPIShPath.au3>
#include <WinAPIConv.au3>
#include <Constants.au3>
#include <SendMessage.au3>
;-----------------------------------------------------

;-----------------------------------------------------
Opt("MustDeclareVars", 1)
;-----------------------------------------------------

;-----------------------------------------------------
;#Variables
Local $aCmdLine = _WinAPI_CommandLineToArgv($CmdLineRaw)
Local $Max_Scanner_Process = "MaxCMDScanner.exe"
Local $iPID
Local $sOutput
Local $sCommand
Local $icout = 99
Local $proc_hWnd
Local $WinList
Local $PCount
Local $iProc_count
;-----------------------------------------------------



_Force_Run_As_Administrator()
_Scan_file()



Func _Scan_file()
        IF ($aCmdLine[0] == 2) Then
            IF ($aCmdLine[1] == "/scan") Then 
                IF FileExists($aCmdLine[2]) Then
                    While 1
                        While WinExists("MaxCMDScanner")  
                            ControlClick("MaxCMDScanner", "", '[CLASS:Button; INSTANCE:1]')
                            WinClose("MaxCMDScanner")
                            $icout -= 1
                            If $icout < 1 Then ExitLoop
                        WEnd
                        IF ProcessExists($Max_Scanner_Process) Then
                            $PCount = ProcessList(_ProcessGetName(@AutoItPID))
                            IF ($PCount[0][0] > 1) Then
                                $iProc_count = $PCount[0][0] - 1
                            Else
                                $iProc_count = $PCount[0][0]
                            EndIF
                                ToolTip(@CRLF & "      MaxCLIScannerr: There are  " & $PCount[0][0] - 1 & " scans waiting, please wait      " & @CRLF &  " ", @DesktopWidth / 2 - 135 , 130)
                                Sleep(1000)
                        Else
                            ToolTip("")
                            $sCommand = "C:\Program Files\Max Secure Anti Virus Plus\MaxCMDScanner.exe /C /V /CM /E /DRIVES:" & '"' & $aCmdLine[2] & '"'
                            $iPID = Run($sCommand, "C:\Program Files\Max Secure Anti Virus Plus\", @SW_HIDE, $STDERR_MERGED)
                            While 1
                                IF ProcessExists($iPID) Then
                                    ToolTip(@CRLF & "      MaxCLIScannerr: A file is currently being scanned, please wait...      " & @CRLF &  " ", @DesktopWidth / 2 - 160 , 50)
                                    $proc_hWnd = _GetPIDWindows($iPID)
                                    IF $proc_hWnd Then 
                                        ControlSend($proc_hWnd, "", "", "{ENTER}")
                                        Sleep(555)
                                    EndIf
                                Else
                                    ExitLoop
                                EndIf
                            WEnd
                            $sOutput = StdoutRead($iPID)
                            ConsoleWrite($sOutput)
                            ExitLoop
                        EndIf
                    WEnd
                Else
                    ConsoleWrite("can not find file:" & $aCmdLine[2])
                    Exit
                EndIf
            Else
                ConsoleWrite('just can send "/scan" switch')
                Exit
            EndIf
        Else
            ConsoleWrite('command sample: "C:\MaxCLIScanner.exe" /scan "C:\eicar.com"')
            Exit
        EndIf
EndFunc

Func _Force_Run_As_Administrator()
        ;--------------------------------
        ;Run Ad Admin
        IF Not IsAdmin() Then
            ShellExecute(@AutoItExe, "", "", "runas")
            ProcessClose(@AutoItPID)
            Exit
        Else
            ;Is Administrator
        EndIf
        ;--------------------------------
EndFunc

func _GetPIDWindows($PID)
    $WinList = WinList()
    for $i = 1 to $WinList[0][0]
        if WinGetProcess($WinList[$i][1]) = $PID then 
            Return $WinList[$i][1]
        EndIf
    Next
    Return 0
EndFunc

 

As you said, this antivirus has problems
And another one of them is that if we are scanning a file and editing a text file at the same time, we will see that sometimes we will get a space in our text!

Edited by r2du-soft
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...