How deactivate-reactivate a hardware component and start a service by script / command-line ?

  • Thread starter Thread starter MoiMeme
  • Start date Start date
M

MoiMeme

Hi,

have my USB Wireless dongle constatntly dropping ( although drivers ok and
up-to-date, constantly awake etc)

Have to deactivate it, re-activate it and start a services which it relies
on to most often regain connetcion to the web.

Doing theses maneuvers is tedious so I am looking for a simpler way to
achieve it with one click on a batch or script

Possible ?

The dongle I use is an ASUS Wireless USB Network Adapter ( with Ralink
drivers)

TIA
 
MoiMeme said:
Hi,

have my USB Wireless dongle constatntly dropping ( although drivers ok and
up-to-date, constantly awake etc)

Have to deactivate it, re-activate it and start a services which it relies
on to most often regain connetcion to the web.

Doing theses maneuvers is tedious so I am looking for a simpler way to
achieve it with one click on a batch or script

Possible ?

The dongle I use is an ASUS Wireless USB Network Adapter ( with Ralink
drivers)

TIA

Hard to say. Perhaps stopping, then restarting the service would be
sufficient. With my own USB dongle the commands would be:
@echo off
net stop ANIWZCSdService
net start ANIWZCSdService
 
Ok for the service. That works.

But most often I have to deactivate the dongle in hardware manager, the
reactivate it .

Can that be done as well ?

( Soory for direct reply ! was not intended so !)
 
Here is a batch file that can enable/disable a device. You invoke it with a
parameter of "enable" or "disable".
@echo off
if /i "%1"=="enable" goto start
if /i "%1"=="disable" goto start
goto :eof

:Start
setlocal enabledelayedexpansion
set Desc=Name: USB Mass Storage Device
set HWID=x
set count=0
set found=no

devcon hwids "usb\vid*" > c:\usb.txt
for /F "tokens=*" %%* in (c:\usb.txt) do (
set /a count=!count! + 1
if /i "%%*"=="%Desc%" set found=yes& set count=1
if !found!==yes if !count!==4 set HWID=%%*
)
echo HWID=!HWID!
devcon %1 "!HWID!"
endlocal
del c:\usb.txt

By setting Desc=Name: USB Mass Storage Device in the batch file, it will
enable/disable a USB-connected disk. Your challenge is to find the
appropriate description for your wireless dongle. You can do it like so:
- Execute these commands from a Command Prompt:
devcon hwids "usb\vid*" > c:\usb.txt
notepad c:\usb.txt
- Look for an identifier for your dongle.

You can download devcon.exe from here:
http://download.microsoft.com/download/1/1/f/11f7dd10-272d-4cd2-896f-9ce67f3e0240/devcon.exe
 
Thanks. That works fine !

Many thanks again.

Pegasus (MVP) said:
Here is a batch file that can enable/disable a device. You invoke it with
a parameter of "enable" or "disable".
@echo off
if /i "%1"=="enable" goto start
if /i "%1"=="disable" goto start
goto :eof

:Start
setlocal enabledelayedexpansion
set Desc=Name: USB Mass Storage Device
set HWID=x
set count=0
set found=no

devcon hwids "usb\vid*" > c:\usb.txt
for /F "tokens=*" %%* in (c:\usb.txt) do (
set /a count=!count! + 1
if /i "%%*"=="%Desc%" set found=yes& set count=1
if !found!==yes if !count!==4 set HWID=%%*
)
echo HWID=!HWID!
devcon %1 "!HWID!"
endlocal
del c:\usb.txt

By setting Desc=Name: USB Mass Storage Device in the batch file, it will
enable/disable a USB-connected disk. Your challenge is to find the
appropriate description for your wireless dongle. You can do it like so:
- Execute these commands from a Command Prompt:
devcon hwids "usb\vid*" > c:\usb.txt
notepad c:\usb.txt
- Look for an identifier for your dongle.

You can download devcon.exe from here:
http://download.microsoft.com/download/1/1/f/11f7dd10-272d-4cd2-896f-9ce67f3e0240/devcon.exe
 
Back
Top