Jump to content

Possible to make an IP changer?


Recommended Posts

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- #
Link to comment
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

Link to comment
Share on other sites

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 ]---
Link to comment
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

Link to comment
Share on other sites

  • Moderators

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

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.

Link to comment
Share on other sites

  • 11 months later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...