x
This website is using cookies. We use cookies to ensure that we give you the best experience on our website. More info. That's Fine
HPC:Factor Logo 
 
Latest Forum Activity

Windows Command to Eject USB Wifi Adapter?

Jake Page Icon Posted 2016-11-02 7:55 PM
#
Avatar image of Jake
Moderator
H/PC Vanguard

Posts:
2,828
Location:
Choking on the stench of ambition in Washington DC
Status:
I'm putting together a very basic script to switch between wifi adapters (my usb wifi can do ad hoc; the laptop's internal wifi can not).

To return to default internal wifi, I've found the steps to disconnect the usb wifi's network, to re-enable internal wifi, but I'm interested in a final command for my .bat file that would eject the usb wifi adapter, preferably a command that would tell me it was safe to remove it.

I was able to google most of this but haven't found help with eject command.

Any advice?
Jake
 Top of the page
stingraze Page Icon Posted 2016-11-03 8:09 AM
#
Avatar image of stingraze
Subscribers
H/PC Vanguard

Posts:
3,678
Location:
Japan
Status:
I guess you already looked at these, but it's a 50/50 chance so. :-)
http://superuser.com/questions/520755/bat-file-to-disable-ethernet-adaptor-and-then-reenable-it-after-windows-log-in
http://superuser.com/questions/104400/enable-disable-wireless-interface-in-a-bat-file

Further Reading: http://www.robvanderwoude.com/devcon.php

Should be easy to modify it to suit your needs?

Update: As for the eject command, it might be better to use VBScript or devcon? Just my thoughts...

Edited by stingraze 2016-11-03 8:25 AM
 Top of the page
Jake Page Icon Posted 2016-11-03 1:22 PM
#
Avatar image of Jake
Moderator
H/PC Vanguard

Posts:
2,828
Location:
Choking on the stench of ambition in Washington DC
Status:
Many thanks for your post and helpful links. I hadn't seen them, but I had sort of gotten to their point anyway with the wifi-enabling current .bat:

@echo on
netsh wlan disconnect interface="Wi-Fi 2"
timeout /t 1
netsh interface set interface "Wi-fi" admin=enable

So that shuts down the usb wifi network and re-enable the internal wifi (which searches and finds my default router right away).

I think devcon is probably the way, but it's a bit above my paygrade:

https://msdn.microsoft.com/en-us/library/windows/hardware/ff544746(v=vs.85).aspx#ddk_example_35_remove_devices_by_device_instance_id_pattern_tools

I worry that I will permanently remove something...

Thanks again,
Jake
 Top of the page
Jake Page Icon Posted 2016-11-03 2:40 PM
#
Avatar image of Jake
Moderator
H/PC Vanguard

Posts:
2,828
Location:
Choking on the stench of ambition in Washington DC
Status:
Okay, I figured out how to run the devcon command.

Using this (cab extraction section) http://superuser.com/questions/1002950/quick-method-to-install-devcon-exe I was able to avoid the 100+ mb install just to get devcon.exe

Then get device's pid from its properties in Device Manager.

Then in admin-rum cmd, run:

devcon remove "USB\VID_148F&PID_3070"

(obviously, that's my usb adapter's name)

The trouble is, the devcon command removes all manually-inserted networks (which is how I set up ad hoc to begin with). So I'm forced to rebuild those...

Hmmm,
Jake
 Top of the page
stingraze Page Icon Posted 2016-11-03 8:18 PM
#
Avatar image of stingraze
Subscribers
H/PC Vanguard

Posts:
3,678
Location:
Japan
Status:
Thank you for the detailed steps you took.

Hmmm..... I think you're getting close!

Good Hunting!

Edited by stingraze 2016-11-03 8:32 PM
 Top of the page
Jump to forum:
Seconds to generate: 0.140 - Cached queries : 63 - Executed queries : 8