rasim Posted December 26, 2007 Share Posted December 26, 2007 Hello! My daily work include in itself technical support for offices and small photostudios. In many clients computers installed NOD32 antivirus, but some offices and photostudios not have access to internet and their antivirus bases outdated. It`s cause risk for business and clients trust. For relieve to create and update NOD32 antivirus base i write this script. This script in compiled type plased on flash drive with autorun.inf file. [autorun] open=AntivirUpdater.exe icon=update.ico Shell\RunSC\command=AntivirUpdater.exe Shell\RunSC=Update NOD32 bases... After plug flash drive on computer just double click on "My computer", right click on flash drive and select "Update NOD32 bases". expandcollapse popup;======================================================================== ; ; Program version: 1.0 ; Program name: Antivir Updater ; Description: For automatic NOD32 antivirus base update ; Note(s): Works from flash drive; Tested on Microsoft Windows XP ; Requirement(s): Flash drive with 20 mb free space ; Autor(s): R.Gilman (a.k.a. rasim) ; ;======================================================================== #NoTrayIcon If WinExists("Antivir Updater") Then Exit FileInstall("c:\Program Files\AutoIt3\Examples\GUI\sampleAVI.avi", @TempDir & "\", 1) #include <GuiConstants.au3> #include <Array.au3> Dim $Program_Path = StringTrimRight(RegRead("HKLM\SOFTWARE\Eset\Nod\CurrentVersion\Info", "InstallDir"), 1) Global $File_Array[1] Dim $FlashDrive Local $drive_Array = DriveGetDrive("Removable") For $i = 1 To $drive_Array[0] If $drive_Array[$i] <> "a:" And FileExists($drive_Array[$i] & "\AntivirUpdater.exe") Then $FlashDrive = $drive_Array[$i] EndIf Next $hGui = GUICreate("Antivir Updater", 300, 200, -1, -1, Default, $WS_EX_APPWINDOW + $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) If $Program_Path = "" And Not FileExists(@ProgramFilesDir & "\Eset") Then _MsgBox(16, "Error", "NOD32 not installed on this computer") Exit ElseIf $Program_Path = "" And FileExists(@ProgramFilesDir & "\Eset") Then If _MsgBox(52, "Warning", "NOD32 installed on this computer incorrect." & @CRLF & _ "Do you wish to continue?") = 7 Then Exit EndIf Global $nProcess[2] = ["nod32kui.exe", "nod32krn.exe"] If Not ProcessExists("nod32kui.exe") Then _MsgBox(16, "Error", "NOD32 not started on this computer!" & @CRLF & _ "Please start NOD32 antivirus before update base") Exit EndIf $Run_Button = GUICtrlCreateButton("Ok", 10, 170, 50, 20) GUICtrlSetCursor(-1, 0) $Close_Button = GUICtrlCreateButton("Close", 240, 170, 50, 20) GUICtrlSetCursor(-1, 0) GUICtrlCreateGroup("Select task", 10, 10, 150, 100) $Update_Antivir_Radio = GUICtrlCreateRadio("Update base from " & StringUpper($FlashDrive) & " drive", 15, 40, 140, 20) GUICtrlSetCursor(-1, 0) $Create_Antivir_Radio = GUICtrlCreateRadio("Create base to " & StringUpper($FlashDrive) & " drive", 15, 70, 140, 20) GUICtrlSetCursor(-1, 0) GUICtrlCreateGroup("", -99, -99, 1, 1) $Anim = GUICtrlCreateAvi(@TempDir & "\sampleAVI.avi", -1, 210, 30, 20, 20) $Progress_Label = GUICtrlCreateLabel("", 170, 75, 100, 15) $Progress = GUICtrlCreateProgress(170, 95, 120, 15) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE, $Close_Button ExitLoop Case $Run_Button If BitAND(GUICtrlRead($Update_Antivir_Radio), $GUI_UNCHECKED, GUICtrlRead($Create_Antivir_Radio), $GUI_UNCHECKED) Then _MsgBox(16, "Error", "Select task") ContinueCase EndIf If BitAND(GUICtrlRead($Update_Antivir_Radio), $GUI_CHECKED) Then If Not FileExists($FlashDrive & "\base\updfiles") Then _MsgBox(16, "Error", "Antivirus base not found on " & $FlashDrive & "\ drive" & @CRLF & _ "You must create base") ContinueCase EndIf Preparing($FlashDrive & "\base") If UBound($File_Array) = 1 Then _MsgBox(16, "Error", "Path to NOD32 not found") ContinueCase EndIf UpdateCreate($Program_Path, 1) If @error Then ContinueCase EndIf If BitAND(GUICtrlRead($Create_Antivir_Radio), $GUI_CHECKED) Then If Not FileExists($Program_Path & "\updfiles") Then _MsgBox(16, "Error", "Antivirus base not found on this computer" & @CRLF & _ "You must update base from internet") ContinueCase EndIf Preparing($Program_Path) If UBound($File_Array) = 1 Then _MsgBox(16, "Error", "Path to NOD32 not found") ContinueCase EndIf UpdateCreate($FlashDrive & "\base") If @error Then ContinueCase EndIf EndSwitch WEnd Func Preparing($sPath) Local $First_File = FileFindFirstFile($sPath & "\*.*") If @error Then Return While 1 $Next_File = FileFindNextFile($First_File) If @error Then ExitLoop $Full_File = $sPath &"\"& $Next_File If StringRegExp($Full_File, "(?i)\.nup|\.ver|\.00.$") Then _ArrayAdd($File_Array, $Full_File) ElseIf StringInStr(FileGetAttrib($Full_File), "D") And $Next_File = "updfiles" Then Preparing($Full_File) EndIf WEnd FileClose($First_File) EndFunc Func UpdateCreate($sDest_Path, $Flag = "") Local $i, $percent, $Ubound = UBound($File_Array) -1 GUICtrlSetState($anim, $GUI_AVISTART) If $Flag Then ConfigAntivirService(@ComSpec & " /c sc failure nod32krn reset= 300 actions= take//take//take/", 1) If @error Then Return SetError(1) Else DirRemove($sDest_Path & "\updfiles", 1) FileDelete($sDest_Path & "\nod32.00?") EndIf For $i = 1 To $Ubound $percent = Round(($i / $Ubound) * 100) GUICtrlSetData($Progress_Label, $percent & "% done") GUICtrlSetData($Progress, $percent) If StringInStr($File_Array[$i], "updfiles") Then FileCopy($File_Array[$i], $sDest_Path & "\updfiles\", 9) Else FileCopy($File_Array[$i], $sDest_Path & "\", 9) EndIf Next GUICtrlSetData($Progress, 100) GUICtrlSetData($Progress_Label, "Done") Sleep(400) If $Flag Then ConfigAntivirService(@ComSpec & " /c sc failure nod32krn reset= 300 actions= restart/1/restart/1/restart/1") If @error Then Return SetError(1) Else If DirGetSize($sDest_Path & "\updfiles") = 0 Then _MsgBox(16, "Error", "Antivirus base not create") Return SetError(1) EndIf EndIf _MsgBox(64, "Success", "Antivirus base create\updated successful") GUICtrlSetData($Progress, 0) GUICtrlSetData($Progress_Label, "") GUICtrlSetState($anim, $GUI_AVISTOP) EndFunc Func ConfigAntivirService($sParam, $sStop = 0) Local $StdOut Switch $sStop Case 1 $StdOut = Run($sParam, "", @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD) If StringInStr($StdOut, "FAILED") Then _MsgBox(16, "Error", "Not configure NOD32 service") Return SetError(1) EndIf If ProcessExists("nod32krn.exe") Then For $i = 0 To UBound($nProcess) -1 $StdOut = Run(@ComSpec & " /c taskkill.exe /f /im " & $nProcess[$i], "", @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD) If StringInStr($StdOut, "FAILED") Then _MsgBox(16, "Error", "Not configure NOD32 service") Return SetError(1) EndIf Next DirRemove($Program_Path & "\updfiles", 1) FileDelete($Program_Path & "\nod32.00?") EndIf Return Case Else $StdOut = Run(@ComSpec & " /c sc start nod32krn", "", @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD) If StringInStr($StdOut, "FAILED") Then _MsgBox(16, "Error", "Not configure NOD32 service") Return SetError(1) EndIf If Not ShellExecute(@ProgramFilesDir & "\Eset\nod32kui.exe", "/WAITSERVICE") Then _ _MsgBox(16, "Error", "NOD32 antivirus are not started. Please reboot your computer") EndSwitch EndFunc Func _MsgBox($mType, $mTitle, $mText) $mRet = DllCall("user32.dll", "int", "MessageBox", "HWnd", $hGui, "str", $mText, "str", $mTitle, "int", $mType) Return $mRet[0] EndFunc Func OnExitFunc() GUICtrlSetState($anim, $GUI_AVICLOSE) FileDelete(@TempDir & "\sampleAVI.avi") EndFunc Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now