Jump to content

Internet Browser Disabler


JustinReno
 Share

Recommended Posts

After seeing Swift's script (IEDisabler?), I thought that it just wasn't easy enough to add new web browsers efficently. So, I made a much simpler one using arrays.

HotKeySet("`", "_Start")
HotKeySet("~", "_Stop")

$GetDefaultBrowser = RegRead("HKCR\HTTP\Shell\Open\Command", "")
$GetLastSection = StringSplit($GetDefaultBrowser, "\")
$GetProcessName = StringSplit($GetLastSection[$GetLastSection[0]], """")

Global $InternetProcesses[3] = ["iexplore.exe", "firefox.exe", $GetProcessName[1]], $Started, $Start, $Password

If RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run", "InternetDisabler") = 1 Then
    $Password = FileRead(@WindowsDir&"\InternetDisabler.txt")
    $Started = 1
    FileDelete(@WindowsDir&"\InternetDisabler.txt")
    RegDelete("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run", "InternetDisabler")
EndIf

While 1
    Sleep(10)
    If ProcessExists("TaskMgr.exe") Then ProcessClose("TaskMgr.exe")
    If $Started = 1 Then
        For $I = 0 To UBound($InternetProcesses) - 1
            If ProcessExists($InternetProcesses[$I]) Then 
                ProcessClose($InternetProcesses[$I])
                MsgBox(16, $InternetProcesses[$I], "Internet has been disabled on your user account", 3)
            EndIf
        Next
    EndIf
WEnd

Func _Start()
    If $Start = 0 Then  $Password = InputBox("Internet Disabler", "Please enter a password:", "", "*")
    $Started = 1
    $Start = 1
EndFunc

Func _Stop()
    $AskForPassword = InputBox("Internet Disabler", "Please enter your password:", "", "*")
    If $AskForPassword = $Password Then Exit
    If $AskForPassword <> $Password Then MsgBox(16, "Internet Disabler", "Incorrect.")
EndFunc

Func OnAutoItExit()
    If $Started = 1 Then
        If @Compiled = 0 Then RegWrite("HKEY_LOCAL_MACHINE\Softare\Microsoft\Windows\CurrentVersion\Run", "InternetDisabler", "REG_SZ", @AutoItExe & " " & @ScriptFullPath)
        If @Compiled = 1 Then RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run", "InternetDisabler", "REG_SZ", @ScriptFullPath)
        FileWrite(@WindowsDir&"\InternetDisabler.txt", $Password)
    EndIf
EndFunc

PS: Don't give me crap for this being just another "Justin" script. (You all know what I mean.)

Edited by JustinReno
Link to comment
Share on other sites

Func OnAutoItExit()
    If @exitMethod = 0 Or 1 Or 2 Or 3 Or 4 And $Started = 1 Then
        If @Compiled = 0 Then RegWrite("HKEY_LOCAL_MACHINE\Softare\Microsoft\Windows\CurrentVersion\Run", "InternetDisabler", "REG_SZ", @AutoItExe & " " & @ScriptFullPath)
        If @Compiled = 1 Then RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run", "InternetDisabler", "REG_SZ", @ScriptFullPath)
        FileWrite(@WindowsDir&"\InternetDisabler.txt", $Password)
    EndIf
EndFunc

What you wrote looked like several comparisons with numeric values. When Or gets a number, it interprets it as False if it is 0 and True for any other number. What you wrote would always return True.

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Link to comment
Share on other sites

You also might want to take a look at reading the registry to get the default browser then close that process

HKCR\http\shell\open\command

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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