Page 1 of 1 1
Topic Options
#208650 - 2014-03-03 09:29 AM Help with Network Switch Script.
matzas Offline
Fresh Scripter

Registered: 2006-10-15
Posts: 12
hi all,

We have several laptops, I need to make sure none of them will connect to the Local Network and to other network (WiFi, Netstick, Modem, Etc) at the same time.

I thought of a script that:

-will check the status of each network card. (for not enable a disabled card)
-will check if the physical (LAN) card is connected.
if LAN is connected and some other network cards are connected it will disable the other card.
if LAN is disconnected it will enable back the other network card (not the ones that were disabled before the script).

the script will run in hide console, in the background, and will do it's checks every 2 seconds.

i thought to use GetCurrentSSID() and GetIPOptions() but i don't know how to disable or enable the network card.

thanks in advance,

Amir.

Top
#208653 - 2014-03-03 03:39 PM Re: Help with Network Switch Script. [Re: matzas]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
have you considered enabling this feature in bios?
_________________________
!

download KiXnet

Top
#208655 - 2014-03-03 04:04 PM Re: Help with Network Switch Script. [Re: matzas]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
This works for me.
I stuffed it in a function because you may be busing it a few times and then a function may save some code lines and make it more readable.

 Code:
Break on

$connection = "Connection name goes here"
$state = "state goes here (Enabled or Disabled)"

SetConnectionState($connection, $state)


Function SetConnectionState($connection, $state)
	If Trim($connection) = ""
		Exit 87
	EndIf
	If $state <> "Enabled" And $state <> "Disabled"
		Exit 87
	EndIf

	$shellcommand = 'NetSH interface set interface "' + $connection + '" ' + $state
	Shell $shellcommand
	
	Exit @ERROR
EndFunction
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 466 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.05 seconds in which 0.022 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org