Jump to content

netsh example


Dirk98
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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)
Link to comment
Share on other sites

$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
Link to comment
Share on other sites

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. :)

Link to comment
Share on other sites

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

  • Recently Browsing   0 members

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