HeyHo Leute!
Ich bin gerade am Xampp einrichten gewesen und war gerade bei den Subdomains : ). Dazu muss man die Windows Hosts Datei verändern und es war mir zu umständlich Notepad als Admin auszuführen und dann die Datei zu öffnen.
Also hab ich mir schnell ein AutoIt Script gemacht, dass die Datei verändert
Das Programm ist ziemlich selbsterklärend und keine große Sache. Trotzdem finde ich es sehr hilfreich.
Hier noch ein Bild:
Spoiler anzeigen
[Blockierte Grafik: http://img5.imagebanana.com/img/oydchb5b/hostseditor.png]
und hier der Quelltext:
Spoiler anzeigen
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.6.1
Author: xxlolimanxx
Script Function:
Edits the Host file under %windir%\system32\drivers\etc\host and adds a entry
#ce ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]; Script Start - Add your code below here
[/autoit] [autoit][/autoit] [autoit]#RequireAdmin
#NoTrayIcon
$hostdir=@WindowsDir&'\System32\drivers\etc\hosts'
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Host Editor - Copyrights xxlolimanxx", 368, 86, 192, 124)
$Button1 = GUICtrlCreateButton("-->Add Entry<--", 120, 44, 161, 33, $WS_GROUP)
$Input1 = GUICtrlCreateInput("adress", 40, 12, 129, 21)
$Label1 = GUICtrlCreateLabel("From", 8, 16, 27, 17)
$Label2 = GUICtrlCreateLabel("To", 180, 16, 17, 17)
$Input2 = GUICtrlCreateInput("adress", 208, 12, 137, 21)
$Button2 = GUICtrlCreateButton("Show Host File", 0, 68, 81, 17, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$read_input1=GUICtrlRead($Input1)
$read_input2=GUICtrlRead($Input2)
if $read_input1='adress' or $read_input2='adress' Then
MsgBox(16,'Fail', 'You have to change the Inputs ;)')
Else
$file_open=FileOpen($hostdir,0)
$file_read=FileRead($file_open)
FileClose($file_open)
$file_open=FileOpen($hostdir,2)
FileWrite($file_open,$file_read&@CRLF&$read_input2&' '&$read_input1)
FileClose($file_open)
if @error=1 Then
MsgBox(16,'Fail','Error due writing in the file. Sorry :S')
Else
MsgBox(64,'Done','Done ;)')
EndIf
EndIf
Case $Button2
ShellExecute('notepad.exe',$hostdir)
EndSwitch
WEnd
Viel Spaß und einen schönen Abend noch!
mfg XXlolimanxx