Sign in to follow this  
Followers 0
tsue12

how to

2 posts in this topic

hi, im new to autoit, i need to enter to local security police to add programs that i dont what to allow, i want to do this automatically with a simple double click on an autoit program so it add the values to local security , but the thing is that i dont know much of autoit, if someone could help me thanks

Share this post


Link to post
Share on other sites



To block a process in WinNT

An example to block notepad. It does work with the registry so use at own risk. Functions extracted from CMenu program and I have not updated since.

Global Const $IDYES = 6

If MsgBox(0x40024, Default, 'Block Notepad?') = $IDYES Then
    $processblock = 'notepad.exe'
EndIf

_ProcessBlock()
RunWait('notepad.exe')

Exit

Func _ProcessBlock()
    ; Add process block for select processes
    Dim $processblock
    Local $key, $command
    If @OSTYPE <> 'WIN32_NT' Then Return $processblock = ''
    If $processblock <> '' Then
        $key = 'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options'
        If @Compiled Then
            $command = '"' & @ScriptFullPath & '" /dummy'
        Else
            $command = '"' & @AutoItExe & '" "' & @ScriptFullPath & '" /dummy'
        EndIf
        If StringInStr($processblock, '|') Then
            $processarray = StringSplit($processblock, '|')
            For $i = 1 To $processarray[0]
                RegWrite($key & '\' & $processarray[$i], 'debugger','Reg_sz', $command)
            Next
        Else
            RegWrite($key & '\' & $processblock, 'debugger','Reg_sz', $command)
        EndIf
    EndIf
EndFunc

Func OnAutoItStart()
    ; A 2nd script instance will exit.
    If StringInStr($CMDLINERAW, '/dummy') Then Exit
    If WinExists(@ScriptName & '_Interpreter') Then Exit
    AutoItWinSetTitle(@ScriptName & '_Interpreter')
EndFunc

Func OnAutoItExit()
    ; Blocked processes will be unblocked.
    Dim $processblock, $silenterror
    Local $key, $exitcode
    If @OSTYPE = 'WIN32_NT' And $processblock <> '' Then
        $key = 'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options'
        If StringInStr($processblock, '|') Then
            $processarray = StringSplit($processblock, '|')
            For $i = 1 To $processarray[0]
                If RegDelete($key & '\' & $processarray[$i]) = 2 Then
                    $exitcode = True
                    If Not $silenterror Then
                        MsgBox(0x10, 'Error', 'Registry key for ' & $processarray[$i] & ' still exists', 2)
                    EndIf
                EndIf
            Next
        Else
            If RegDelete($key & '\' & $processblock) = 2 Then
                $exitcode = True
                If Not $silenterror Then
                    MsgBox(0x10, 'Error', 'Registry key for ' & $processblock & ' still exists', 2)
                EndIf
            EndIf
        EndIf
    EndIf
    If $exitcode Then Exit -1
EndFunc

Choosing No will show Notepad, choosing Yes will block Notepad and then exit the script. Both options will undo the blocking of Notepad though changes could be made.

:)

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  
Followers 0