Sign in to follow this  
Followers 0
AzKay

Possible to make an IP changer?

9 posts in this topic

Well, I saw somehwere you can make batch files to do it

This one changes it:

@Echo Setting IP address to <Your NEW IP> @Echo Off  netsh interface ip set address name="Local Area Connection" static <THE NEW IP> <SUBNET MASK> <DEFAULT GATEWAY> 1

This one changes it back:

@Echo Setting IP address to DHCP assigned. @Echo Off netsh interface ip set address "Local Area Connection" dhcp @Echo Setting DNS to DHCP assigned. @Echo Off netsh interface ip set dns "Local Area Connection" dhcp

So, would it be possible to do something like this using autoit?


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites



take a look at @COMSPEC.

Hi,

I think what w0uter means it, every batch command can be run like it is with _RunDOS() or Run( ... @COMSPEC...)

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I created a script for users who move between our different depots with their laptops. Here is the SwitchDepot function. It pulls the info from an ini file, but you should be able to deciper what is going on.

Func SwitchDepot($aDepot)
 SplashTextOn('','Switching Depot, Please wait ...')
 RunAsSet('administrator',@ComputerName,'merc230')
 $DepotIPType = IniRead($IniFileName, $aDepot, "Type", "Not Found")
 If $DepotIPType = 'DHCP' Then
  $Result = RunWait(@ComSpec & " /c " & 'netsh interface ip set address "Local Area Connection" dhcp','c:\',@SW_HIDE)
 Else
  $ipaddr = IniRead($IniFileName,$aDepot,'ipaddr','')
  $subnetmask = IniRead($IniFileName,$aDepot,'subnetmask','')
  $gateway = IniRead($IniFileName,$aDepot,'gateway','')
  $metric = IniRead($IniFileName,$aDepot,'metric','')
  $Result = RunWait(@ComSpec & " /c " & 'netsh interface ip set address "Local Area Connection" static ' & $ipaddr & ' ' & $subnetmask & ' ' & $gateway & ' ' & $metric,'c:\',@SW_HIDE)
  $DnsArray = StringSplit(IniRead($IniFileName,$aDepot,'dns',''),'|')
  If $DnsArray[0] <> 0 Then
   For $i = 1 To $DnsArray[0]
    If $i = 1 Then
     $Result = RunWait(@ComSpec & " /c " & 'netsh interface ip set dns "Local Area Connection" static ' & $DnsArray[$i] & ' primary','c:\',@SW_HIDE)
    Else
     $Result = RunWait(@ComSpec & " /c " & 'netsh interface ip add dns "Local Area Connection" ' & $DnsArray[$i] & ' index=' & $i,'c:\',@SW_HIDE)
    EndIf
   Next
  EndIf
 EndIf
 SplashOff()
EndFunc
Edited by sandyd

----[ SandyD ]---

Share this post


Link to post
Share on other sites

HI,

maybe you should **** your password. :D

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Thanks, Ill try it out


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

Oops maybe I should have!


----[ SandyD ]---

Share this post


Link to post
Share on other sites

That's nice sandyd... but I think he was talking about your public IP :D maybe not :D ?


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

It won't work if the connection name is different, not "Local Area Connection". Best is use WMI

Share this post


Link to post
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
Sign in to follow this  
Followers 0