how to say via a script a if a network is a wireless network ?

P

Pierre

hi,

as in "my network places | properties", each kind of network have a
different icon (wireless, lan, vpn, etc), windows _knows_ how to
distinguish the networks type.

I would like to create a script (.WSF) which when run on a PC find all
wireless networks and disable them. do you have any idea on how to
list all wireless networks on a PC ?

TIA,
Pierre
 
P

Pegasus [MVP]

Pierre said:
hi,

as in "my network places | properties", each kind of network have a
different icon (wireless, lan, vpn, etc), windows _knows_ how to
distinguish the networks type.

I would like to create a script (.WSF) which when run on a PC find all
wireless networks and disable them. do you have any idea on how to
list all wireless networks on a PC ?

TIA,
Pierre

Unfortunately Windows does not always report wireless adapters correctly. I
have a wireless PCMCIA adapter and Windows thinks that it is an ordinary
Ethernet adapter. Try the batch file below. It is a VB Script file wrapped
up in a batch file. If you state a little more clearly what output you expec
then I can adjust it to suit your requirements.
@echo off
set Scr=c:\TempVBS.vbs
set Ethernet=0
set Wireless=9
set VB=echo^>^>%Scr%
cd 1>nul 2>%Scr%
%VB% Set oWMIService = GetObject("winmgmts:\\.\root\CIMV2")
%VB% Set colItems = oWMIService.ExecQuery( _
%VB% "SELECT * FROM Win32_NetworkAdapter",,48)
%VB% For Each oItem In colItems
%VB% If Not IsNull(oItem.NetConnectionStatus) Then
%VB% WScript.Echo oItem.Name
%VB% If oItem.AdapterTypeId = %Ethernet% _
%VB% Then WScript.Echo "Ethernet adapter"
%VB% If oItem.AdapterTypeId = %Wireless% _
%VB% Then WScript.Echo "Wireless adapter"
%VB% wscript.echo
%VB% End If
%VB% Next
cscript //nologo %Scr%
del %Scr%
 
P

Pierre

thanks for your answer :)
Unfortunately Windows does not always report wireless adapters correctly.I
have a wireless PCMCIA adapter and Windows thinks that it is an ordinary
Ethernet adapter.

I plan to run it on laptops computer with on-board WiFi adapters.
Try the batch file below. It is a VB Script file wrapped
up in a batch file. If you state a little more clearly what output you expec
then I can adjust it to suit your requirements.

I'm not especially interested in any output, only in enabling or
disabling wireless adapters.
maybe oItem.Enable() and/or oItem.Disable() do the trick ?

Pierre
 
P

Pegasus [MVP]

thanks for your answer :)
Unfortunately Windows does not always report wireless adapters correctly.
I
have a wireless PCMCIA adapter and Windows thinks that it is an ordinary
Ethernet adapter.

I plan to run it on laptops computer with on-board WiFi adapters.
Try the batch file below. It is a VB Script file
wrapped
up in a batch file. If you state a little more clearly what output you
expec
then I can adjust it to suit your requirements.

I'm not especially interested in any output, only in enabling or
disabling wireless adapters.
maybe oItem.Enable() and/or oItem.Disable() do the trick ?

Pierre

=====================

I have been looking for some time for a method based on WMI to
enable/disable a device, without success. Until I find one I have to use
devcon.exe as in the following batch file. You can get devcon.exe from here:
http://download.microsoft.com/download/1/1/f/11f7dd10-272d-4cd2-896f-9ce67f3e0240/devcon.exe

@echo off
goto Start
---------------------------------------------------
Enable or disable a device from the Command Prompt.
Prerequisite: d:\Tools\devcon.exe
16.4.2006 FNL
---------------------------------------------------
:Start
setlocal enabledelayedexpansion
set Adapter=Broadcom NetXtreme Fast Ethernet

if /i "%1"=="enable" goto go
if /i "%1"=="disable" goto go
echo Syntax: Device enable / disable
goto :eof

:go
set HWID=x
set count=0
set found=no
devcon hwids "PCI\*" > c:\device.txt
for /F "tokens=*" %%* in (c:\device.txt) do (
set /a count=!count! + 1
if /i "%%*"=="Name: %Adapter%" set found=yes& set count=1
if !found!==yes if !count!==3 set HWID=%%*
)
if %found%==yes (
echo HWID=!HWID!
devcon %1 "!HWID!"
) else (
echo Device "%Adapter%" not found.
)
endlocal
del c:\device.txt

You would need to adjust the line
set Adapter=Broadcom NetXtreme Fast Ethernet
to suit your own requirements. The adapter name "Broadcom NetXtreme Fast
Ethernet" comes directly from the VB Script that I posted in my first reply.
 
P

Pierre

when I run the script on my laptop I get this answer:

Broadcom NetXtreme 57xx Gigabit Controller
Ethernet adapter

Intel(R) PRO/Wireless 3945ABG Network Connection
Ethernet adapter

Carte réseau 1394
Ethernet adapter

where the wireless adapter is seen as regular ethernet adapter :(
I have to find another way...

thanks for your help.
 
P

Pegasus [MVP]

when I run the script on my laptop I get this answer:

Broadcom NetXtreme 57xx Gigabit Controller
Ethernet adapter

Intel(R) PRO/Wireless 3945ABG Network Connection
Ethernet adapter

Carte réseau 1394
Ethernet adapter

where the wireless adapter is seen as regular ethernet adapter :(
I have to find another way...

thanks for your help.

===========

This is exactly the problem I found. You can, of course, hard-code the
adapter names that you feed to devcon.exe but his is not really what you
asked for. Sorry . . .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top