Jump to content
Sign in to follow this  
Dirk98

netsh example

Recommended Posts

Dirk98

Guys, does anyone know netsh command?

I need an example of full command to set IP address to the network interface "Local Area Connection" , static, 192.168.3.35, subnet 255.255.255.0 gateway 192.168.3.1.

It is here in the link below, but I don't understand how to syntax it properly (need a concrete example):

Netsh Commands for Interface IP

Many thanks.

Share this post


Link to post
Share on other sites
herewasplato

Sure - now I see this post of yours... :-)

I replied to your other thread and I suggested that you search the forum for netsh - but I also gave you some code that will change your IP settings "the hard way":

http://www.autoitscript.com/forum/index.ph...st&p=400661

-MSP-


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites
ChrisL

Guys, does anyone know netsh command?

I need an example of full command to set IP address to the network interface "Local Area Connection" , static, 192.168.3.35, subnet 255.255.255.0 gateway 192.168.3.1.

It is here in the link below, but I don't understand how to syntax it properly (need a concrete example):

Netsh Commands for Interface IP

Many thanks.

$netname = "Local Area Connection"
$newIp = "192.168.3.35"
$newSubnet = "255.255.255.0"
$newDG = "192.168.3.1"

runwait ('netsh interface ip set address name=' & '"' & $netname & '" static ' & $newIP & ' '& $newSubnet & ' ' & $newDG & ' 1',"",@SW_Hide)

and if your interested this is dhcp

$netname = "Local Area Connection"
runwait ('netsh interface ip set address name=' & '"' & $netname & '" dhcp', "", @SW_HIDE)

Share this post


Link to post
Share on other sites
Dirk98

Guys, THANK you so much!

Can't wait to try them all out.

(Didn't think anyone would have wanted to waste his time on this request).

Dirk.

Share this post


Link to post
Share on other sites
Dirk98

$netname = "Local Area Connection"
$newIp = "192.168.3.35"
$newSubnet = "255.255.255.0"
$newDG = "192.168.3.1"

runwait ('netsh interface ip set address name=' & '"' & $netname & '" static ' & $newIP & ' '& $newSubnet & ' ' & $newDG & ' 1',"",@SW_Hide)

and if your interested this is dhcp

$netname = "Local Area Connection"
runwait ('netsh interface ip set address name=' & '"' & $netname & '" dhcp', "", @SW_HIDE)
Chrisl, what a quaint and compact solution you suggested there! Worked like a charm. And it's so easy compared to the monster codes that are far beyond my depth. :)

If I were entering it as a command line what it would look like? Could you please extract the command line from this:

runwait ('netsh interface ip set address name=' & '"' & $netname & '" static ' & $newIP & ' '& $newSubnet & ' ' & $newDG & ' 1',"",@SW_Hide)

Thanks again!

Edited by Dirk98

Share this post


Link to post
Share on other sites
Dirk98

If I were entering it as a command line what it would look like? Could you please extract the command line from this:

runwait ('netsh interface ip set address name=' & '"' & $netname & '" static ' & $newIP & ' '& $newSubnet & ' ' & $newDG & ' 1',"",@SW_Hide)

Thanks again!

Is it something like

netsh interface ip set address name Local Area Connection 192.168.3.35 255.255.255.0 192.168.3.1

?

Sorry, I couldn't figure this out when I asked in the beginning, and it doesn't work now when I'm trying to manually enter it in START/RUN.

Don't get me wrong though, the script works perfect. I'm just trying to do some reverse engineering on it. :)

Share this post


Link to post
Share on other sites
ChrisL

netsh interface ip set address name= "Local Area Connection" 192.168.3.35 255.255.255.0 192.168.3.1 1

Note name= and speach marks and the additional space 1 at the end

Edited by ChrisL

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.