Skip to content

Instantly share code, notes, and snippets.

@jrw254
Created June 27, 2020 14:57
Show Gist options
  • Select an option

  • Save jrw254/ac3edf8bf5acc721fc148345dcc04b8b to your computer and use it in GitHub Desktop.

Select an option

Save jrw254/ac3edf8bf5acc721fc148345dcc04b8b to your computer and use it in GitHub Desktop.
A basic IP Changer I found while spelunking the interwebs.
;Found: https://autohotkey.com/board/topic/26821-basic-ip-helper-gui-to-releaserenew-get-external/
;
; Archived on: 6/27/2020
; Archived by: JRW254/Sabedth
;
; Mod Status: Changed GUi color from default to Slate Grey: #708090
#SingleInstance, Force
#NoEnv
TempFile=%A_Temp%\ip_temp.txt
Gui, Add, Groupbox, w100 h100,IP Address:
Gui, Add, Text, vIPList x20 yp+15 r4 w85
Gui, Add, Button, gGetIP w50, Refresh
Gui, Add, Button, gIPInfo w30 yp x+2, Info
Gui, Add, Button, gReleaseIP +Section y10, Release IP
Gui, Add, Button, gRenewIP y+0 wp xs, Renew IP
Gui, Add, Button, gFlushDNS y+0 wp xs, Flush DNS
Gui, Add, Button, gGetExternalIP y+0 wp xs, External IP
Gui, Show, ,IP Helper
Gui, Color, 708090
GoSub, GetIP
Return
RenewIP:
SplashTextOn, , 20,Working, Renewing IP
RunWait %comspec% /c "ipconfig /renew > %TempFile%",,Hide
SplashTextOff
GoSub, GetIP
GoSub, GetDetails
Return
ReleaseIP:
SplashTextOn, , 20,Working, Releasing IP
RunWait %comspec% /c "ipconfig /release > %TempFile%",,Hide
SplashTextOff
GoSub, GetIP
GoSub, GetDetails
Return
FlushDNS:
SplashTextOn, , 20,Working, Flushing DNS
RunWait %comspec% /c "ipconfig /flushdns > %TempFile%",,Hide
SplashTextOff
GoSub, GetDetails
Return
GetExternalIP:
SplashTextOn, , 20,Working, Getting External IP
URLDownloadToFile, http://automation.whatismyip.com/n09230945.asp, %TempFile%
SplashTextOff
FileRead, detail, %A_Temp%\ip_temp.txt
If (StrLen(detail) > 15) ;Yeah, I still need to learn RegEx.
{
FileDelete, %TempFile%
FileAppend, ERROR, %TempFile%
}
GoSub, GetDetails
Return
IPInfo:
SplashTextOn, , 20,Working, Getting IP Info
RunWait %comspec% /c "ipconfig.exe > %TempFile%",,Hide
SplashTextOff
GoSub, GetDetails
Return
GetIP:
SplashTextOn, , 20,Working, Getting IP List
IPList=
(
%A_IPAddress1%
%A_IPAddress2%
%A_IPAddress3%
%A_IPAddress4%
)
GuiControl, , IPList,%IPList%
SplashTextOff
Return
GetDetails:
FileRead, detail, %A_Temp%\ip_temp.txt
FileDelete, %A_Temp%\ip_temp.txt
StringReplace, detail, detail, `r`n`r`n,`r`n, all
EnvGet PCName, COMPUTERNAME
detail:= "IP details for " . PCName . ":`r`n" . detail
Msgbox, ,Details, %detail%
Return
GuiClose:
ExitApp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment