Swiss Army knife of this and that

Block Site in HOST file

$hostfile = "C:\windows\system32\drivers\etc\hosts"
 
;InputBox features: Title=Yes, Prompt=Yes, Default Text=Yes
If Not IsDeclared("sInputBoxAnswer") Then Dim $sInputBoxAnswer
$website = InputBox("Block site","Type in the site you want to block access to?","WWW.SPAM.COM"," ","-1","-1","-1","-1")
Select
   Case @Error = 0 ;OK - The string returned is valid
	   $error = FileWriteLine($hostfile,"127.0.0.1       " & $website)
	   If $error = "0" Then
			MsgBox(16,"Warning!","Couldn't write to file")
		Else

Send Email With Public IP

You can setup scheduler to run the compiled script. It will check your public IP and send an email when it's changed

#cs ----------------------------------------------------------------------------
 
 AutoIt Version: 3.2.6.0
 Author:         Aaron Moline (aaron.moline@kpunderground.com)
 
 Script Function:
	Script is ment to be ran as a scheduled service. Depending on how many times
	your public ip address is the frequency in which you should sent the task to
	run. It will create a file called "App.log" the logs the application activity. 

Get MAC

#include <Process.au3>
#include <file.au3>
;AutoItSetOption ( "0", RunErrorsFatal )
Opt("RunErrorsFatal", 0) 
$n1 = 10
$n2 = 20
$n3 = 71
$n4 = 210
$username = "user"
$password = "password"
 
 RunWait(@ComSpec & " /c " & "getmac /S " & $n1 & "."  & $n2 & "."  & $n3 & "."  & $n4 & " /U " &$username & " /p " & $password  &  "> getmac.txt", "", @SW_HIDE)
$rc = Filereadline("getmac.txt",4)
 
MsgBox(0,$n1 & $n2 & $n3 & $n4 ,$rc) 
_FileWriteLog( "Mac.txt", $rc)

Profile Backup

Script copies specified folders. Requires two fies "Extensions.txt" and "Settings.ini"

Settings INI would look like this: 
[ADMINUSERS]
FILE=Adminusers.txt
 
[POWERUSERS]
FILE=PowerUsers.txt

Extensions.txt would look like this:
*.rtf
*.dot
*.xls
*.xlt
*.ppt
*.ppa
*.pps
*.pot
*.pdf
*.ai
*.eps
*.p65
*.t65

#include <File.au3>
Dim $ext, $x
$bkupDir = "f:\" & @ComputerName
$fsource = @UserProfileDir & "\Desktop\"
$fileDest = $bkupDir & "\Documents"
$FavSource = @UserProfileDir & "\Favorites\"
$favDest = $bkupDir & "\Favorites"

Screen Shot Talker

This script came in handy trying to see what the user seen. If the user was too busy to call the help desk and it wasn't critical, they simple did a "print screen" and this script would send an email with a screen shot and some network information for trouble shooting. It uses BLAT for windows: http://www.blat.net/194/

;~ Program will take a screen shot using the DLL called capt.dll and then send it to 
;~ a whomever is listed in the 'settings.ini' file. The settings.ini file also contains

Remotely Enable DNS Registration

Dim $val, $GUID, $i
;~ ;------------------------------------------CODE--------------------------------------------
$regkey = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces"
For $i = 1 to 100
    $var = RegEnumKey($regkey, $i)
    If @error <> 0 then ExitLoop
		$info = RegRead($regkey & "\" & $var, "RegistrationEnabled")
		If $info = "0" Then
			RegWrite($regkey & "\" & $var, "RegistrationEnabled","REG_DWORD","1")
		Else
		EndIf

Talking Computer Script

Simple script to make the computer talk. Fun to execute remotely on someone's PC.

AutoItSetOption("RunErrorsFatal",0)
SoundSetWaveVolume(100)
$talk = "Help!, Help!, Help!... I can't feel my CPU anymore!!!" 
 
_Talk($talk)
Func _Talk($sText)
    $tempFile = @TempDir & '\talktemp.vbs'    ; Set the temp file
    FileWriteLine($tempFile, 'Dim Talk' & @CRLF & _
    'Set Talk = WScript.CreateObject("SAPI.SpVoice")' & _
    @CRLF & 'Talk.Speak "' & $sText & '"'); Add contents to the temp file
    RunWait('Wscript.exe talktemp.vbs', @TempDir); Run the VBScript
    ;FileDelete($tempFile)

MS Agent

Script shows an example of how invoke Microsoft Agent and speak.

Dim $objAgent,$objCharacter,$strAgentName,$strAgentPath,$strCmd,$strText
Global $d
$strAgentName = "Merlin"
$strAgentPath = "C:\Windows\Msagent\Chars\" & $strAgentName & ".acs"
$objAgent = ObjCreate("Agent.Control.2")
$objAgent.Connected = 1
$objAgent.Characters.Load ($strAgentName, $strAgentPath)
$objCharacter = $objAgent.Characters.Character($strAgentName)
$objCharacter.Show()
;------------------------------------------------------------------------------
;CODE BELOW

Set USB Ports Read Only

;READ Reg Key
;[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies]
;"WriteProtect"=dword:00000001
 
;Read RegKey and then create if it doesn't exsist
$key = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies", "WriteProtect",)
	IF @error = -1 Then
		RegWrite ( "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies" ,"WriteProtect", "REG_DWORD", "0" ) 
		MsgBox(0,"WriteProtect", "Registry key has been created")
	EndIf
 
	IF $key = "1" Then

Enable - Disable USB Ports

;----------------------------------------
;Read RegKey and then create if it doesn't exsist
;----------------------------------------
$key = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR", "Start",)
	IF @error = -1 Then
		RegWrite ( "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR" ,"Start", "REG_DWORD", "3" ) 
		MsgBox(0,"Start", "Registry key has been created")
	EndIf
 
	If $key = "4" Then
		MsgBox(0,"USB PORTS", "USB Ports are currently Enabled")
		Elseif $key = "4" Then
		MsgBox(0,"USB PORTS", "USB Ports are currently Disabled")
	EndIf