Jump to content

Recommended Posts

Posted

Is there a way from the command line that I can find out which wireless profile is in use at the moment? I am trying to set static IP's when I am on specific networks and sometimes I am not available to access the router where I am at. Here is my code that I am trying to use to accomplish possible meaningless feat:

CODE
While 1

Sleep(1000)

$test = StringSplit(@IPAddress1,".")

If $test[4] = "7" Then

Else

ShellExecute("netsh", "interface ip set address wireless static 192.168.1.50 255.255.255.0 192.168.1.1 1")

ProcessWaitClose("netsh.exe")

ShellExecute("netsh", 'interface ip set dns "Wireless Network Connection" static 192.168.1.1 primary')

ProcessWaitClose("netsh.exe")

Else

EndIf

If $test[4] = "7" Then

Else

ShellExecute("netsh", "interface ip set address wireless static 192.168.2.7 255.255.255.0 192.168.2.1 1")

ProcessWaitClose("netsh.exe")

ShellExecute("netsh", "interface ip set dns 'Wireless Network Connection' static 192.168.2.1 primary")

ProcessWaitClose("netsh.exe")

EndIf

WEnd

I guess it would be alot easier for me to do this code if I could specify what wireless profile I am connected to and then use this command to set the ip. Any help or ideas suggestions are greatly appreciated.

Thanks

Posted

If each "wireless profile" uses a different SSID...

...then some wireless NIC drivers write the current SSID to one of these subkeys:

HKEY_LOCAL_MACHINE\

SYSTEM\

CurrentControlSet\

Control\

Class\

{4D36E972-E325-11CE-BFC1-08002bE10318}\

00xxx

Other than the method above, I'm not sure how to tell.

Maybe a WMI guru will stop by your thread.

In your code, you might see if these two lines

ShellExecute("netsh",...

ProcessWaitClose("netsh.exe")

can be replaced by

ShellExecuteWait("netsh",..

Also, maybe these two lines

If $test[4] = "7" Then

Else

can be replaced by

If $test[4] <> "7" Then

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

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
×
×
  • Create New...