Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

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

Reply
 
Old 01-22-2009   #1 (permalink)
MoiMeme


 
 

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

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



My System SpecsSystem Spec
Old 01-22-2009   #2 (permalink)
Pegasus \(MVP\)


 
 

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


"MoiMeme" <antispam@xxxxxx> wrote in message
news:%23fuetfHfJHA.5408@xxxxxx
Quote:

> 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


My System SpecsSystem Spec
Old 01-22-2009   #3 (permalink)
MoiMeme


 
 

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

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 !)

"Pegasus (MVP)" <I.can@xxxxxx> a écrit dans le message de news:
%23eUT7kHfJHA.2384@xxxxxx
Quote:

>
> "MoiMeme" <antispam@xxxxxx> wrote in message
> news:%23fuetfHfJHA.5408@xxxxxx
Quote:

>> 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
>
>

My System SpecsSystem Spec
Old 01-22-2009   #4 (permalink)
Pegasus \(MVP\)


 
 

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

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/downlo...240/devcon.exe


"MoiMeme" <antispam@xxxxxx> wrote in message
news:%23NoQsHIfJHA.5408@xxxxxx
Quote:

> 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 !)
>
> "Pegasus (MVP)" <I.can@xxxxxx> a écrit dans le message de news:
> %23eUT7kHfJHA.2384@xxxxxx
Quote:

>>
>> "MoiMeme" <antispam@xxxxxx> wrote in message
>> news:%23fuetfHfJHA.5408@xxxxxx
Quote:

>>> 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
>>
>>
>
>

My System SpecsSystem Spec
Old 01-22-2009   #5 (permalink)
MoiMeme


 
 

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

Thanks. That works fine !

Many thanks again.

"Pegasus (MVP)" <I.can@xxxxxx> a écrit dans le message de news:
e$VHaqIfJHA.500@xxxxxx
Quote:

> 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/downlo...240/devcon.exe
>
>
> "MoiMeme" <antispam@xxxxxx> wrote in message
> news:%23NoQsHIfJHA.5408@xxxxxx
Quote:

>> 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 !)
>>
>> "Pegasus (MVP)" <I.can@xxxxxx> a écrit dans le message de news:
>> %23eUT7kHfJHA.2384@xxxxxx
Quote:

>>>
>>> "MoiMeme" <antispam@xxxxxx> wrote in message
>>> news:%23fuetfHfJHA.5408@xxxxxx
>>>> 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
>>>
>>>
>>
>>
>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
noob: PS script fails, but runs from command line PowerShell
Running a command from inside a script, command line is corrupted PowerShell
Running a Command line script from within powershell. PowerShell
Script from command-line PowerShell
NET START STOP Service Command Line Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46