Jump to content

How to update Malwarebytes rules to an infected PC


Docfxit
 Share

Go to solution Solved by Docfxit,

Recommended Posts

I'm having a problem coping files.  At line #43 I'm getting a message saying Failed to copy.

I have deleted the file manually and copied the file to that folder manually.  I don't understand why this script won't copy the file.

;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
; Before you run this script you should update Malwarebytes on a good working PC
;   ************  Please note:  This is not official from Malwarebytes.  I'm testing this out.
;                 Run at your own risk.
;
; This script will do two things:
;   1. Copy the latest updates in the Malwarebytes folder to this directory in MalwarebytesUpdates.
;       You need to copy this script and MalwarebytesUpdates to the PC you would like to apply the updates to.
;   2. Copy the updates in the folder MalwarebytesUpdates to the installed Malwarebytes rules folder.
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
#RequireAdmin
#include <FileConstants.au3>
Global $ProgramFiles = ""

_RunCommonCode()


;_CopyToThisFolder()

_CopyUpdatesToRulesFolder()

Exit

Func _CopyToThisFolder()
    If Not FileExists(@WorkingDir & "\MalwarebytesUpdates") Then DirCreate(@WorkingDir & "\MalwarebytesUpdates")
    $UpdateDir = @WorkingDir & "\MalwarebytesUpdates"
    FileCopy($ProgramFiles & "rules.ref", $UpdateDir & "\rules.ref", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "swissarmy.ref", $UpdateDir & "\swissarmy.ref", $FC_OVERWRITE)
    If FileExists($ProgramFiles & "mbam-setup.exe") Then FileCopy($ProgramFiles & "mbam-setup.exe", $UpdateDir & "\mbam-setup.exe", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\build.conf", $UpdateDir & "\build.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\database.conf", $UpdateDir & "\database.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\manifest.conf", $UpdateDir & "\manifest.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\net.conf", $UpdateDir & "\net.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\settings.conf", $UpdateDir & "\settings.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\statistics.conf", $UpdateDir & "\statistics.conf", $FC_OVERWRITE)
EndFunc   ;==>_CopyToThisFolder

Func _CopyUpdatesToRulesFolder()
    $UpdateDir = @WorkingDir & "\MalwarebytesUpdates"
    If FileCopy($UpdateDir & "rules.ref", $ProgramFiles & "\rules.ref", $FC_OVERWRITE) = 1 Then
        MsgBox(0, "", "Success")
    Else
        MsgBox(0, "", "Failed to Copy")     ; <<< I'm getting this message
    EndIf
    FileCopy($UpdateDir & "swissarmy.ref", $ProgramFiles & "\swissarmy.ref", $FC_OVERWRITE)
    If FileExists($UpdateDir & "mbam-setup.exe") Then FileCopy($UpdateDir & "mbam-setup.exe", $ProgramFiles & "\mbam-setup.exe", $FC_OVERWRITE)
    FileCopy($UpdateDir & "Configuration\build.conf", $ProgramFiles & "\build.conf", $FC_OVERWRITE)
    FileCopy($UpdateDir & "Configuration\database.conf", $ProgramFiles & "\database.conf", $FC_OVERWRITE)
    FileCopy($UpdateDir & "Configuration\manifest.conf", $ProgramFiles & "\manifest.conf", $FC_OVERWRITE)
    FileCopy($UpdateDir & "Configuration\net.conf", $ProgramFiles & "\net.conf", $FC_OVERWRITE)
    FileCopy($UpdateDir & "Configuration\settings.conf", $ProgramFiles & "\settings.conf", $FC_OVERWRITE)
    FileCopy($UpdateDir & "Configuration\statistics.conf", $ProgramFiles & "\statistics.conf", $FC_OVERWRITE)
EndFunc   ;==>_CopyUpdatesToRulesFolder

Func _RunCommonCode()
    ;AutoIt_Debugger_Command:Disable_Debug
    Global $LineCalledFrom = @ScriptLineNumber
    AutoItSetOption("TrayIconDebug", 1) ;0-off
    ; Set so that tray displays current line number
    If @OSVersion = 'Win_7' Then
        $ProgramFiles = "C:\Users\All Users\Malwarebytes\Malwarebytes Anti-Malware\"
    Else
        $ProgramFiles = "C:\Documents and Settings\All Users\Application Data\Malwarebytes\Malwarebytes Anti-Malware\"
    EndIf
    ;AutoIt_Debugger_Command:Enable_Debug
EndFunc   ;==>_RunCommonCode

Thanks,

Docfxit

Link to comment
Share on other sites

Thank you for catching that.  I must be tired.

I am now having success in coping file rules.ref.  But I not having success coping Configurationbuild.conf

The @WorkingDir = D:DnloadMalwarebytes Anti-Malware

Note: it does have a space in it.

I don't understand why it works for rules.ref on line 41

but it doesn't work for Configurationbuild.conf on line 50

;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
; Before you run this script you should update Malwarebytes on a good working PC
;   ************  Please note:  This is not official from Malwarebytes.  I'm testing this out.
;                 Run at your own risk.
;
; This script will do two things:
;   1. Copy the latest updates in the Malwarebytes folder to this directory in MalwarebytesUpdates.
;       You need to copy this script and MalwarebytesUpdates to the PC you would like to apply the updates to.
;   2. Copy the updates in the folder MalwarebytesUpdates to the installed Malwarebytes rules folder.
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
#RequireAdmin
#include <FileConstants.au3>
Global $ProgramFiles = ""

_RunCommonCode()


;_CopyToThisFolder()

_CopyUpdatesToRulesFolder()

Exit

Func _CopyToThisFolder()
    If Not FileExists(@WorkingDir & "\MalwarebytesUpdates") Then DirCreate(@WorkingDir & "\MalwarebytesUpdates")
    $UpdateDir = @WorkingDir & "\MalwarebytesUpdates\"
    FileCopy($ProgramFiles & "rules.ref", $UpdateDir & "rules.ref", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "swissarmy.ref", $UpdateDir & "swissarmy.ref", $FC_OVERWRITE)
    If FileExists($ProgramFiles & "mbam-setup.exe") Then FileCopy($ProgramFiles & "mbam-setup.exe", $UpdateDir & "mbam-setup.exe", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\build.conf", $UpdateDir & "build.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\database.conf", $UpdateDir & "database.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\manifest.conf", $UpdateDir & "manifest.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\net.conf", $UpdateDir & "net.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\settings.conf", $UpdateDir & "settings.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\statistics.conf", $UpdateDir & "statistics.conf", $FC_OVERWRITE)
EndFunc   ;==>_CopyToThisFolder

Func _CopyUpdatesToRulesFolder()
    $UpdateDir = @WorkingDir & "\MalwarebytesUpdates\"
    If FileCopy($UpdateDir & "rules.ref", $ProgramFiles & "rules.ref", $FC_OVERWRITE) = 1 Then
        MsgBox(0, "", "Success Rules.ref")  ; <<< I'm getting this message
    Else
        Msgbox(0, "", "Folder = " & $UpdateDir & "rules.ref")
    EndIf
    FileCopy($UpdateDir & "swissarmy.ref", $ProgramFiles & "swissarmy.ref", $FC_OVERWRITE)
    If FileExists($UpdateDir & "mbam-setup.exe") Then FileCopy($UpdateDir & "mbam-setup.exe", $ProgramFiles & "mbam-setup.exe", $FC_OVERWRITE)
    If FileCopy($UpdateDir & "Configuration\build.conf", $ProgramFiles & "build.conf", $FC_OVERWRITE) = 1 Then
        MsgBox(0, "", "Success")
    Else
        Msgbox(0, "", "Folder = " & $UpdateDir & "Configuration\build.conf")    ; <<< I'm getting this message
    EndIf
    FileCopy($UpdateDir & "Configuration\database.conf", $ProgramFiles & "database.conf", $FC_OVERWRITE)
    FileCopy($UpdateDir & "Configuration\manifest.conf", $ProgramFiles & "manifest.conf", $FC_OVERWRITE)
    FileCopy($UpdateDir & "Configuration\net.conf", $ProgramFiles & "net.conf", $FC_OVERWRITE)
    FileCopy($UpdateDir & "Configuration\settings.conf", $ProgramFiles & "settings.conf", $FC_OVERWRITE)
    FileCopy($UpdateDir & "Configuration\statistics.conf", $ProgramFiles & "statistics.conf", $FC_OVERWRITE)
EndFunc   ;==>_CopyUpdatesToRulesFolder

Func _RunCommonCode()
    ;AutoIt_Debugger_Command:Disable_Debug
    Global $LineCalledFrom = @ScriptLineNumber
    AutoItSetOption("TrayIconDebug", 1) ;0-off
    ; Set so that tray displays current line number
    If @OSVersion = 'Win_7' Then
        $ProgramFiles = "C:\Users\All Users\Malwarebytes\Malwarebytes Anti-Malware\"
    Else
        $ProgramFiles = "C:\Documents and Settings\All Users\Application Data\Malwarebytes\Malwarebytes Anti-Malware\"
    EndIf
    ;AutoIt_Debugger_Command:Enable_Debug
EndFunc   ;==>_RunCommonCode

Thanks,

Docfxit

Link to comment
Share on other sites

  • Moderators

Same problem, should be $UpdateDir & "Configurationbuild.conf". In fact, I see about 10 spots at a glance that are going to fail because you fail to include a backslash between your variable and the sub folder.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Thank you for the reply...

$UpdateDir = D:DnloadMalwarebytes Anti-MalwareMalwarebytesUpdates

I'm adding & "Configurationbuild.conf"

I don't see where the slash is missing.  In my first post I had:

$UpdateDir = @WorkingDir & "\MalwarebytesUpdates"

After you pointed out to me I was missing a slash, In post #3 I added a slash

$UpdateDir = @WorkingDir & "\MalwarebytesUpdates\"

Is my thinking wrong?

Thanks,

Docfxit

Link to comment
Share on other sites

I can't figure out how to adjust this GUI.

I'd like to make the box smaller.

Center (Left & Right) the second button.

Add text above each button.

Lower both bottons in the box.

;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
; Before you run this script you should update Malwarebytes on a good working PC
;   ************  Please note:  This is not official from Malwarebytes.  I'm testing this out.
;                 Run at your own risk.
;
; This script will do two things:
;   1. Copy the latest updates in the Malwarebytes folder to this directory in MalwarebytesUpdates.
;       You need to copy this script and MalwarebytesUpdates to the PC you would like to apply the updates to.
;   2. Copy the updates in the folder MalwarebytesUpdates to the installed Malwarebytes rules folder.
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
#RequireAdmin
#include <FileConstants.au3>
#include <GUIConstantsEx.au3>

Global $ProgramFiles = ""
_RunCommonCode()

MainGUI()



Exit

Func MainGUI()
    Local $Button1, $Button2, $msg
    GUICreate("Copy Malwarebytes rules from an updated PC to the PC you want to run it on")

    Opt("GUICoordMode", 2)
    $Button1 = GUICtrlCreateButton("Copy latest Malwarebytes rules to this folder", 100, 160, -1, 25)
    $Button2 = GUICtrlCreateButton("Copy Malwarebytes rules to the working folder5", 30, 160, -1, 25)

    GUISetState()

    ; Run the GUI until the window is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button1
                ; I'd like to have a GUI with two choices.
                ;       Note: run this on an PC with Malwarebytes updated.
                ;  1. Copy latest Malwarebytes rules to this folder
                _CopyToThisFolder()
            Case $msg = $Button2
                ;       Note: Make sure Malwarebytes is installed first
                ;       Note: run this on a PC to copy latest updates to the live directory.
                ;  2. Copy Malwarebytes rules to the working folder
                _CopyUpdatesToRulesFolder()
        EndSelect
    WEnd
EndFunc   ;==>MainGUI

Func _CopyToThisFolder()
    If Not FileExists(@WorkingDir & "\MalwarebytesUpdates") Then DirCreate(@WorkingDir & "\MalwarebytesUpdates")
    $UpdateDir = @WorkingDir & "\MalwarebytesUpdates\"
    FileCopy($ProgramFiles & "rules.ref", $UpdateDir & "rules.ref", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "swissarmy.ref", $UpdateDir & "swissarmy.ref", $FC_OVERWRITE)
    If FileExists($ProgramFiles & "mbam-setup.exe") Then FileCopy($ProgramFiles & "mbam-setup.exe", $UpdateDir & "mbam-setup.exe", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\build.conf", $UpdateDir & "build.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\database.conf", $UpdateDir & "database.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\manifest.conf", $UpdateDir & "manifest.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\net.conf", $UpdateDir & "net.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\settings.conf", $UpdateDir & "settings.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\statistics.conf", $UpdateDir & "statistics.conf", $FC_OVERWRITE)
EndFunc   ;==>_CopyToThisFolder

Func _CopyUpdatesToRulesFolder()
    $UpdateDir = @WorkingDir & "\MalwarebytesUpdates\"
    If FileCopy($UpdateDir & "rules.ref", $ProgramFiles & "rules.ref", $FC_OVERWRITE) = 1 Then
        ;   MsgBox(0, "", "Success Rules.ref")  ; <<< I'm getting this message
    Else
        MsgBox(0, "", "Folder = " & $UpdateDir & "rules.ref")
    EndIf
    FileCopy($UpdateDir & "swissarmy.ref", $ProgramFiles & "swissarmy.ref", $FC_OVERWRITE)
    If FileExists($UpdateDir & "mbam-setup.exe") Then FileCopy($UpdateDir & "mbam-setup.exe", $ProgramFiles & "mbam-setup.exe", $FC_OVERWRITE)
    If FileCopy($UpdateDir & 'build.conf', $ProgramFiles & "Configuration\build.conf", $FC_OVERWRITE) = 1 Then
        ;   MsgBox(0, "", "Success build.conf")
    Else
        MsgBox(0, "", "Folder = " & $UpdateDir & 'Configuration\build.conf') ; <<< I'm getting this message
    EndIf
    FileCopy($UpdateDir & "database.conf", $ProgramFiles & "Configuration\database.conf", $FC_OVERWRITE)
    FileCopy($UpdateDir & "manifest.conf", $ProgramFiles & "Configuration\manifest.conf", $FC_OVERWRITE)
    FileCopy($UpdateDir & "net.conf", $ProgramFiles & "Configuration\net.conf", $FC_OVERWRITE)
    FileCopy($UpdateDir & "settings.conf", $ProgramFiles & "Configuration\settings.conf", $FC_OVERWRITE)
    FileCopy($UpdateDir & "statistics.conf", $ProgramFiles & "Configuration\statistics.conf", $FC_OVERWRITE)
EndFunc   ;==>_CopyUpdatesToRulesFolder

Func _RunCommonCode()
    ;AutoIt_Debugger_Command:Disable_Debug
    Opt('MustDeclareVars', 1)
    Global $Button1, $Button2, $msg
    Global $LineCalledFrom = @ScriptLineNumber
    AutoItSetOption("TrayIconDebug", 1) ;0-off
    ; Set so that tray displays current line number
    If @OSVersion = 'Win_7' Then
        $ProgramFiles = "C:\Users\All Users\Malwarebytes\Malwarebytes Anti-Malware\"
    Else
        $ProgramFiles = "C:\Documents and Settings\All Users\Application Data\Malwarebytes\Malwarebytes Anti-Malware\"
    EndIf
    ;AutoIt_Debugger_Command:Enable_Debug
EndFunc   ;==>_RunCommonCode

Thank you,

Docfxit

Link to comment
Share on other sites

  • Moderators

I'd like to make the box smaller.

 

So look at the help file for GUICreate and read for yourself what the parameters do.

Center (Left & Right) the second button.

 

Again, look at the help file for GUICtrlCreateButton

Add text above each button.

 

Look in the help file for GUICtrlCreateLabel

Lower both bottons in the box.

 

Guess what the suggestion is going to be??

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

I have tried to define everything.  I can't figure out what I have done wrong.

I managed to set the size of the box.

I managed to show the first message.

I can't figure out why the buttons don't show and why the rest of the lines don't show.

;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
; Before you run this script you should update Malwarebytes on a good working PC
;   ************  Please note:  This is not official from Malwarebytes.  I'm testing this out.
;                 Run at your own risk.
;
; This script will do two things:
;   1. Copy the latest updates in the Malwarebytes folder to this directory in MalwarebytesUpdates.
;       You need to copy this script and MalwarebytesUpdates to the PC you would like to apply the updates to.
;   2. Copy the updates in the folder MalwarebytesUpdates to the installed Malwarebytes rules folder.
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
#RequireAdmin
#include <FileConstants.au3>
#include <GUIConstantsEx.au3>

Global $ProgramFiles = ""
_RunCommonCode()

MainGUI()



Exit

Func MainGUI()
    Local $Button1, $Button2, $msg
    GUICreate("Copy Malwarebytes rules from an updated PC to the PC you want to run it on", 600, 200)
    Local $iOldOpt = Opt("GUICoordMode", 2)

    Local $iWidthCell = 500 ;Width of text
    GUICtrlCreateLabel("    Note: run this on an PC with Malwarebytes updated.", 100, 30, $iWidthCell)
    $Button1 = GUICtrlCreateButton("Copy latest Malwarebytes rules to this folder", 100, 160, -1, 25)
    GUICtrlCreateLabel("    Note: Make sure Malwarebytes is installed first", -1, 0) ; next line
    GUICtrlCreateLabel("Note: run this on a PC to copy latest updates to the live directory.", 0, 0) ; next line and next cell
    GUICtrlCreateLabel("2. Copy Malwarebytes rules to the working folder", -3 * $iWidthCell, 0) ; next line Cell1
    $Button2 = GUICtrlCreateButton("Copy Malwarebytes rules to the working folder5", 30, 160, -1, 25)

    GUISetState(@SW_SHOW) ; will display an empty dialog box


    ; Run the GUI until the window is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button1
                ; I'd like to have a GUI with two choices.
                ;       Note: run this on an PC with Malwarebytes updated.
                ;  1. Copy latest Malwarebytes rules to this folder
                _CopyToThisFolder()
            Case $msg = $Button2
                ;       Note: Make sure Malwarebytes is installed first
                ;       Note: run this on a PC to copy latest updates to the live directory.
                ;  2. Copy Malwarebytes rules to the working folder
                _CopyUpdatesToRulesFolder()
        EndSelect
    WEnd
EndFunc   ;==>MainGUI

Func _CopyToThisFolder()
    If Not FileExists(@WorkingDir & "\MalwarebytesUpdates") Then DirCreate(@WorkingDir & "\MalwarebytesUpdates")
    $UpdateDir = @WorkingDir & "\MalwarebytesUpdates\"
    FileCopy($ProgramFiles & "rules.ref", $UpdateDir & "rules.ref", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "swissarmy.ref", $UpdateDir & "swissarmy.ref", $FC_OVERWRITE)
    If FileExists($ProgramFiles & "mbam-setup.exe") Then FileCopy($ProgramFiles & "mbam-setup.exe", $UpdateDir & "mbam-setup.exe", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\build.conf", $UpdateDir & "build.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\database.conf", $UpdateDir & "database.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\manifest.conf", $UpdateDir & "manifest.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\net.conf", $UpdateDir & "net.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\settings.conf", $UpdateDir & "settings.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\statistics.conf", $UpdateDir & "statistics.conf", $FC_OVERWRITE)
EndFunc   ;==>_CopyToThisFolder

Func _CopyUpdatesToRulesFolder()
    $UpdateDir = @WorkingDir & "\MalwarebytesUpdates\"
    If FileCopy($UpdateDir & "rules.ref", $ProgramFiles & "rules.ref", $FC_OVERWRITE) = 1 Then
        ;   MsgBox(0, "", "Success Rules.ref")  ; <<< I'm getting this message
    Else
        MsgBox(0, "", "Folder = " & $UpdateDir & "rules.ref")
    EndIf
    FileCopy($UpdateDir & "swissarmy.ref", $ProgramFiles & "swissarmy.ref", $FC_OVERWRITE)
    If FileExists($UpdateDir & "mbam-setup.exe") Then FileCopy($UpdateDir & "mbam-setup.exe", $ProgramFiles & "mbam-setup.exe", $FC_OVERWRITE)
    If FileCopy($UpdateDir & 'build.conf', $ProgramFiles & "Configuration\build.conf", $FC_OVERWRITE) = 1 Then
        ;   MsgBox(0, "", "Success build.conf")
    Else
        MsgBox(0, "", "Folder = " & $UpdateDir & 'Configuration\build.conf') ; <<< I'm getting this message
    EndIf
    FileCopy($UpdateDir & "database.conf", $ProgramFiles & "Configuration\database.conf", $FC_OVERWRITE)
    FileCopy($UpdateDir & "manifest.conf", $ProgramFiles & "Configuration\manifest.conf", $FC_OVERWRITE)
    FileCopy($UpdateDir & "net.conf", $ProgramFiles & "Configuration\net.conf", $FC_OVERWRITE)
    FileCopy($UpdateDir & "settings.conf", $ProgramFiles & "Configuration\settings.conf", $FC_OVERWRITE)
    FileCopy($UpdateDir & "statistics.conf", $ProgramFiles & "Configuration\statistics.conf", $FC_OVERWRITE)
EndFunc   ;==>_CopyUpdatesToRulesFolder

Func _RunCommonCode()
    ;AutoIt_Debugger_Command:Disable_Debug
    Opt('MustDeclareVars', 1)
    Global $Button1, $Button2, $msg
    Global $LineCalledFrom = @ScriptLineNumber
    AutoItSetOption("TrayIconDebug", 1) ;0-off
    ; Set so that tray displays current line number
    If @OSVersion = 'Win_7' Then
        $ProgramFiles = "C:\Users\All Users\Malwarebytes\Malwarebytes Anti-Malware\"
    Else
        $ProgramFiles = "C:\Documents and Settings\All Users\Application Data\Malwarebytes\Malwarebytes Anti-Malware\"
    EndIf
    ;AutoIt_Debugger_Command:Enable_Debug
EndFunc   ;==>_RunCommonCode

Thanks,

Docfxit

Link to comment
Share on other sites

  • Moderators

Comment out the $iOldOpt = Opt("GUICoordMode", 2) line and you'll be able to see them.

Once again, you need to read the help file. GUICoordMode relies on GUICtrlSetPos. You're trying to use relative positioning (why, I have no clue) without first setting the control's position.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Solution

This is what I came up with:

Did I do it correctly?  Should I have done something different?

;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
; Before you run this script you should update Malwarebytes on a good working PC
;    ************  Please note:  This is not official from Malwarebytes.  I'm testing this out.
;                 Run at your own risk.
;
; This script will do two things:
;    1. Copy the latest updates in the Malwarebytes folder to this directory in MalwarebytesUpdates.
;        You need to copy this script and MalwarebytesUpdates to the PC you would like to apply the updates to.
;    2. Copy the updates in the folder MalwarebytesUpdates to the installed Malwarebytes rules folder.
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
#RequireAdmin
#include <FileConstants.au3>
#include <GUIConstantsEx.au3>
#include <ColorConstants.au3>
Global $ProgramFiles = ""

_RunCommonCode()

MainGUI()

Exit

Func MainGUI()
    Local $Button1, $Button3, $msg, $MalwarebytesUpdateAvailable
    Local Const $sFont = "Comic Sans Ms" ; Font type to be used for setting the font of the controls.
    If FileExists(@WorkingDir & "\MalwarebytesUpdates\mbam-setup.exe") Then
        $MalwarebytesUpdateAvailable = "Yes"
        GUICreate("Malwarebytes rules Update", 600, 300)
    Else
        $MalwarebytesUpdateAvailable = "NO"
        GUICreate("Malwarebytes rules Update", 600, 250)
    EndIf
    Local $iWidthCell = 600 ;Width of text
    Local $idLabel = GUICtrlCreateLabel("Copy Malwarebytes rules from an updated PC to the PC you want to run it on.", 100, 30, $iWidthCell)
    GUICtrlSetFont(-1, 11, 400, 4, $sFont) ; Set the font of the previous control.
    GUICtrlSetPos($idLabel, 40, 5)
    GUICtrlSetColor($idLabel, $COLOR_BLUE) ; Set the color of the label control.
    Local $idLabel = GUICtrlCreateLabel("Note: run this on a PC with Malwarebytes updated.", 100, 30, $iWidthCell)
    GUICtrlSetPos($idLabel, 40, 45)
    $Button1 = GUICtrlCreateButton("1. Copy latest Malwarebytes rules to this folder: " & @WorkingDir & "\MalwarebytesUpdates", 100, 160, -1, 25)
    GUICtrlSetPos($Button1, 60, 65)
    GUICtrlSetColor($Button1, $COLOR_GREEN)
    Local $idLabel = GUICtrlCreateLabel("Copy this program " & @ScriptFullPath, 100, 30, $iWidthCell)
    GUICtrlSetPos($idLabel, 40, 120)
    GUICtrlSetColor($idLabel, $COLOR_TEAL)
    Local $idLabel = GUICtrlCreateLabel("And This folder " & @WorkingDir & "\MalwarebytesUpdates", 100, 30, $iWidthCell)
    GUICtrlSetPos($idLabel, 50, 140)
    GUICtrlSetColor($idLabel, $COLOR_TEAL)
    Local $idLabel = GUICtrlCreateLabel("To the PC to be updated", 100, 30, $iWidthCell)
    GUICtrlSetPos($idLabel, 60, 160)
    GUICtrlSetColor($idLabel, $COLOR_TEAL)
    Local $idLabel = GUICtrlCreateLabel("Note: Make sure Malwarebytes is installed on the PC to be updated before you run this.", 100, 30, $iWidthCell)
    GUICtrlSetPos($idLabel, 40, 180)
    If         $MalwarebytesUpdateAvailable = "Yes" Then
Local $idLabel = GUICtrlCreateLabel("If you like you can use this downloaded copy to install Malwarebytes.", 100, 30, $iWidthCell)
    GUICtrlSetPos($idLabel, 40, 200)
    $Button2 = GUICtrlCreateButton("Install/update the Malwarebytes program", 30, 160, -1, 25)
    GUICtrlSetPos($Button2, 60, 220)
    GUICtrlSetColor($Button2, $COLOR_FUCHSIA)
Local $idLabel = GUICtrlCreateLabel("Note: run this on a PC to copy latest updates to the live directory.", 100, 30, $iWidthCell)
    GUICtrlSetPos($idLabel, 40, 250)
    $Button3 = GUICtrlCreateButton("2. Copy Malwarebytes rules to the working folder", 30, 160, -1, 25)
    GUICtrlSetPos($Button3, 60, 270)
    GUICtrlSetColor($Button3, $COLOR_GREEN)
Else
    Local $idLabel = GUICtrlCreateLabel("Note: run this on a PC to copy latest updates to the live directory.", 100, 30, $iWidthCell)
    GUICtrlSetPos($idLabel, 40, 200)
    $Button3 = GUICtrlCreateButton("2. Copy Malwarebytes rules to the working folder", 30, 160, -1, 25)
    GUICtrlSetPos($Button3, 60, 220)
    GUICtrlSetColor($Button3, $COLOR_GREEN)
    EndIf

    GUISetState(@SW_SHOW) ; will display everything

    While 1 ; Run the GUI until the window is closed
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button1
                _CopyToThisFolder()
                MsgBox(0, "", "All files have been copied")
                Exit
            Case $msg = $Button3
                _CopyUpdatesToRulesFolder()
                MsgBox(0, "", "All files have been updated")
                Exit
        EndSelect
    WEnd
EndFunc   ;==>MainGUI

Func _CopyToThisFolder()
    ConsoleWrite("Called _CopyToThisFolder Function" & @CRLF)
    If Not FileExists(@WorkingDir & "\MalwarebytesUpdates") Then DirCreate(@WorkingDir & "\MalwarebytesUpdates")
    $UpdateDir = @WorkingDir & "\MalwarebytesUpdates\"
    If FileCopy($ProgramFiles & "rules.ref", $UpdateDir & "rules.ref", $FC_OVERWRITE) = 1 Then
        ;    MsgBox(0, "", "Success Rules.ref")
    Else
        MsgBox(0, "", "Folder = " & $UpdateDir & "rules.ref")
    EndIf
    FileCopy($ProgramFiles & "swissarmy.ref", $UpdateDir & "swissarmy.ref", $FC_OVERWRITE)
    If FileExists($ProgramFiles & "mbam-setup.exe") Then FileCopy($ProgramFiles & "mbam-setup.exe", $UpdateDir & "mbam-setup.exe", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\build.conf", $UpdateDir & "build.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\database.conf", $UpdateDir & "database.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\manifest.conf", $UpdateDir & "manifest.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\net.conf", $UpdateDir & "net.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\settings.conf", $UpdateDir & "settings.conf", $FC_OVERWRITE)
    FileCopy($ProgramFiles & "Configuration\statistics.conf", $UpdateDir & "statistics.conf", $FC_OVERWRITE)
EndFunc   ;==>_CopyToThisFolder

Func _CopyUpdatesToRulesFolder()
    $UpdateDir = @WorkingDir & "\MalwarebytesUpdates\"
    If FileCopy($UpdateDir & "rules.ref", $ProgramFiles & "rules.ref", $FC_OVERWRITE) = 1 Then
        ;    MsgBox(0, "", "Success Rules.ref")
    Else
        MsgBox(0, "", "Folder = " & $UpdateDir & "rules.ref")
    EndIf
    FileCopy($UpdateDir & "swissarmy.ref", $ProgramFiles & "swissarmy.ref", $FC_OVERWRITE)
    If FileExists($UpdateDir & "mbam-setup.exe") Then FileCopy($UpdateDir & "mbam-setup.exe", $ProgramFiles & "mbam-setup.exe", $FC_OVERWRITE)
    If FileCopy($UpdateDir & 'build.conf', $ProgramFiles & "Configuration\build.conf", $FC_OVERWRITE) = 1 Then
        ;    MsgBox(0, "", "Success build.conf")
    Else
        MsgBox(0, "", "Folder = " & $UpdateDir & 'Configuration\build.conf')
    EndIf
    FileCopy($UpdateDir & "database.conf", $ProgramFiles & "Configuration\database.conf", $FC_OVERWRITE)
    FileCopy($UpdateDir & "manifest.conf", $ProgramFiles & "Configuration\manifest.conf", $FC_OVERWRITE)
    FileCopy($UpdateDir & "net.conf", $ProgramFiles & "Configuration\net.conf", $FC_OVERWRITE)
    FileCopy($UpdateDir & "settings.conf", $ProgramFiles & "Configuration\settings.conf", $FC_OVERWRITE)
    FileCopy($UpdateDir & "statistics.conf", $ProgramFiles & "Configuration\statistics.conf", $FC_OVERWRITE)
EndFunc   ;==>_CopyUpdatesToRulesFolder

Func _RunCommonCode()
    ;AutoIt_Debugger_Command:Disable_Debug
    Opt('MustDeclareVars', 1)
    Global $Button1, $Button2, $Button3, $msg, $UpdateDir
    Global $LineCalledFrom = @ScriptLineNumber
    AutoItSetOption("TrayIconDebug", 1) ;0-off
    ; Set so that tray displays current line number
    If @OSVersion = 'Win_7' Then
        $ProgramFiles = "C:\Users\All Users\Malwarebytes\Malwarebytes Anti-Malware\"
    Else
        $ProgramFiles = "C:\Documents and Settings\All Users\Application Data\Malwarebytes\Malwarebytes Anti-Malware\"
    EndIf
    ;AutoIt_Debugger_Command:Enable_Debug
EndFunc   ;==>_RunCommonCode

Thank you for the pointers,

Docfxit

Edited: Fixed all issues

Edited by Docfxit
Link to comment
Share on other sites

  • Moderators

This is what I came up with:

Did I do it correctly? 

 

Does it do the job you want it to?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

How do you know it is not being run, since you're doing zero error checking? At least put something like this as the first line in the function, so you know it is being called:

ConsoleWrite("Called _CopyToThisFolder Function" & @CRLF)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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...