changehost() Func changehost() ; Ping myserver.domain.com with a timeout of 250ms. Local $iPing = Ping("myserver.domain.com", 250) Local $ipaddress = TCPNameToIP("myserver.domain.com") $Server = "myserver.domain.com" If $iPing Then ; If a value greater than 0 then all is good.. Else ; we need to change the host entry if $ipaddress = "18.104.22.168" Then $OPENHOSTS = FileOpen("C:\WINDOWS\system32\drivers\etc\hosts", 1) FileWrite($OPENHOSTS, "10.10.10.1" & @TAB & $Server & @CRLF) FileClose($OPENHOSTS) ; write to host file 10.10.10.1 and remove entry with 22.214.171.124 this is where i'm confused on how to do that Else $OPENHOSTS = FileOpen("C:\WINDOWS\system32\drivers\etc\hosts", 1) FileWrite($OPENHOSTS, "126.96.36.199" & @TAB & $Server & @CRLF) FileClose($OPENHOSTS) ;write to the host file 188.8.131.52 and remove 10.10.10.1 entry EndIf EndIf EndFunc ;==>changehost
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE