Jump to content
StickyChopstix

Using IP addresses in variables without quotes

Recommended Posts

StickyChopstix
$ipchange = 'netsh interface ipv4 set address "Local Area Connection" static '
$one = 192.168.1.124
$two = 255.255.255.0
$three = 192.168.1.1

Run(@ComSpec & $ipchange & $one & $two & $three)

how would I go about using ip addresses in variables without using quotes?

Share this post


Link to post
Share on other sites
Subz
Posted (edited)

You can't, any reason why you require quotes?

Edited by Subz

Share this post


Link to post
Share on other sites
StickyChopstix
Posted (edited)

 

unknown.png

the "netsh interface ipv4 set address" command doesn't work if the IP is set in quotes

Edited by StickyChopstix

Share this post


Link to post
Share on other sites
Subz

Yes I understand, but why can't you just use:

$ipchange = 'netsh interface ipv4 set address "Local Area Connection" static '
$one = "192.168.1.124"
$two = "255.255.255.0"
$three = "192.168.1.1"
ConsoleWrite("Run('" & @ComSpec & " /c " & $ipchange & $one & " " & $two & " " & $three & "')" & @CRLF)

 

Share this post


Link to post
Share on other sites
StickyChopstix

ah, okay, I see what my problem was. I forgot to add those " " in-between the IPs and the " /c " and #requireadmin. 

Thanks @Subz

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

×