Jump to content

Disconnecting Controllers Easily with Scripts in Windows


Recommended Posts

For games/sims that don't support multiple controllers (Lazy Game Devs!) here is a way to simply click a shortcut that will disable selected controllers without having to manually unplug the USB cords. You can then click a shortcut to enable all controllers.

 

I've done this in Win 7, but I'm fairly certain you can do this in Vista and 8 as well. A bit of setup to begin, but a stich in time saves nine as they say...

 

Step 1

Download the devcon tool.

I shared it at the following link. I have used it with Win7 64

http://www.mediafire.com/download.php?b2igq0q38am229z

Extract and place devcon.exe in a folder of your choice

 

Step 2

Get the Hardware IDs of each game controller from the properties screen in Devices and Printers. Copy and paste each one into a notepad file for reference.

 

- Go to Control Panel\All Control Panel Items\Devices and Printers

- Right click on the controller and select Properties. Select Hardware tab. Select Properties button. Select Details tab. Select the Property drop down menu and select Hardware Ids to get to the screen below. Select the top ID number, right click, copy, then paste it into notepad.

 

HardwareID_zpse6a00f94.png

 

Step 3

Create a .bat file for each controller you want to use on it's own. Also, create a .bat file to enable all controllers.

 

In this example I will create a bat file to disable all but my gamepad.

- Using notepad create a file and save it to the same location you saved the file devon.exe. Name it something like 'Xbox Gamepad.bat'

- In the file you just created in notepad, type the words 'devcon enable' followed by a space, then the ID number in quotation marks of the controller to enable. In this case my gamepad. Paste it from your reference file.

- Type the words 'devcon disable' followed by a space, then the ID number in quotation marks of each controller to disable. I have another 8 controllers to disable. (yes I have too many)

- Save the file

 

The file should look like the following

 

Gamepad_zps87d277fb.png

 

- Create an additional separate bat file for any other controller you want to use as the only controller connected to Windows. I have a bat file to disable all but my gamepad, a bat file for all but my wheel, and a bat file for all but my CH controllers. Save each file separately.

 

- Create a bat file that enables all controllers and name it 'All.bat'. Save it in the same location as devcon.exe. This bat file is the one you can open to have all controllers re-enabled again for games that support multiple controllers.

 

Here is what mine looks like for all my 9 controllers.

 

AllBatFile_zpsdf5d1f44.png

 

Now you should have all your files saved in one folder. Similar to the following.

 

BatFilesFolder_zps1e93fc56.png

 

Step 4

Create a shortcut to each bat file. Place the shortcut somewhere you can click it quick. Here is where mine are.

 

Shorcuts_zpsfadc2afb.png

 

 

That's it. Click on a shortcut to enable your controller(s) of choice. You can verify what controllers are enabled at any time by going to the Game Controller applet. Below you can see just my gamepad, but all 9 of my controllers are physically plugged into my computer's USB ports still.

 

Capture_zps1f34ad7c.png


Edited by Crunch
  • Like 1
Link to comment
Share on other sites

Yes. Thanks. Your post is now a part of my PDF How-to library. :thumbup:

ASUS ROG Maximus VIII Hero, i7-6700K, Noctua NH-D14 Cooler, Crucial 32GB DDR4 2133, Samsung 950 Pro NVMe 256GB, Samsung EVO 250GB & 500GB SSD, 2TB Caviar Black, Zotac GTX 1080 AMP! Extreme 8GB, Corsair HX1000i, Phillips BDM4065UC 40" 4k monitor, VX2258 TouchScreen, TIR 5 w/ProClip, TM Warthog, VKB Gladiator Pro, Saitek X56, et. al., MFG Crosswind Pedals #1199, VolairSim Pit, Rift CV1 :thumbup:

Link to comment
Share on other sites

Sadly despite following this very closely it doesn't work for me. I'm using Win 7 64 home. I stopped the bat file running with the pause key to see what what going on (it flashes by so quick when it runs I had to be fast on the key) I could see that it states "No matching devices found" when trying to either enable or disable any of the devices in my bat files.

 

I have cross checked the device ID's displayed while running Devcon with those displayed in the hardware ID section in device properties very carefully and ensured there were no typo's in the bat file. It just doesn't seem to work.

 

The concept is fine though as I did the task manually and disabled the devices I need to disable via the properties and that removed them from the game controllers list which achieved the end result.

 

Its the long way of going about it but saves me from having to unplug my Thrustmaster MFD's when I fly IL2 as they steal ID's 3 & 4 which my IL2 install needs to see for the rudder pedals and my trim box.

Hawk_5

 

Modules:

A10C, BS2, FC3, P51, CA, UH-1H, Mi-8MTV2

System:

Gigabyte GA-X79UP4 MB, intel 3930k, Coolermaster Siedon 120M liquid cooled, Corsair Vengence Red 16GB 2133Mhz, Gigabyte Geforce GTX680 2GB Super o'clk, intel 520 SSD 240GB,

Seagate Barracuda 2TB HD, Coolermaster Silent Pro 800W PS, Coolermaster CM690 II Case

Link to comment
Share on other sites

  • 5 months later...

My x52 Pro has more than one item in the list on the Details page? There is a (HID) and a (USB). But your instructions do not say which one to pick...

 

There are even more for my new x55 Stick, and that does not include the throttle which has just as many... :cry: And each one can have multiple Hardware IDs too?? :doh: :doh:

 

See Attachment...


Edited by Snacko

Intel I9-10850K (OC @ 5.0ghz) │ Asus Maximus XII Hero │ G.Skill Ripjaws 64GB (4x16GB) DDR4 3200 │ Thermaltake Water 360mm
Gigabyte RTX 4090 Gaming OC 24gb │ 2TB M.2 EVO Pro; 1T M.2 EVO; Sandisk SSD Drives │ 49" Samsung Curved Widescreen │ 28" Touchscreen

- ҉ - Blackshark Cockpit Trainer - ҉ -    Thread   | Download

Link to comment
Share on other sites

Thanks. Rocksmith 2014 hates my Saitek pedals (they have the effect of hitting pressing down constantly( and I've been going in and disabling the HID device rather than unplug it for awhile now, but being able to click a bat file is even easier.

 

Maybe I can go the extra mile and script , disable, launch, enable and just forget it all together. :thumbup:

Link to comment
Share on other sites

Do I have to disable 'all' of the hardware IDs for 'all' of the device functions (HID, USB, etc...)?

Intel I9-10850K (OC @ 5.0ghz) │ Asus Maximus XII Hero │ G.Skill Ripjaws 64GB (4x16GB) DDR4 3200 │ Thermaltake Water 360mm
Gigabyte RTX 4090 Gaming OC 24gb │ 2TB M.2 EVO Pro; 1T M.2 EVO; Sandisk SSD Drives │ 49" Samsung Curved Widescreen │ 28" Touchscreen

- ҉ - Blackshark Cockpit Trainer - ҉ -    Thread   | Download

Link to comment
Share on other sites

Snacko, haven't tried scripting it yet, but when disabling it manually doing the HID device is enough for my case (but disabling the USB instead would make the HID device just disappear, and also worked)... You may just have to play a bit to get the desired effect, but it couldn't hurt to just try the HID device for starters, I don't think...

Link to comment
Share on other sites

I created a batch file like this to disable the device, start my program, and then enable the device again.

 

In the case of rocksmith as long as it's disabled when the game starts it doesn't detect the pedals and doesn't cause an issue. DCS seems pretty much the same way, though I'm not sure it's universal.

 

devcon disable "HID\VID_06A3&PID_0764&REV_0201"

start "c:\Program Files (x86)\Steam\Steam.exe" steam://rungameid/221680

timeout /t 30

devcon enable "HID\VID_06A3&PID_0764&REV_0201"

 

I then created a shortcut on the desktop and set it to run as administrator since it appears devcon needs administrative rights to go ahead and enable/disable devices.

 

Thanks, this is great.


Edited by xaoslaad
Link to comment
Share on other sites

That is handy. Thanks for posting.

 

What is the timeout command for?

Intel I9-10850K (OC @ 5.0ghz) │ Asus Maximus XII Hero │ G.Skill Ripjaws 64GB (4x16GB) DDR4 3200 │ Thermaltake Water 360mm
Gigabyte RTX 4090 Gaming OC 24gb │ 2TB M.2 EVO Pro; 1T M.2 EVO; Sandisk SSD Drives │ 49" Samsung Curved Widescreen │ 28" Touchscreen

- ҉ - Blackshark Cockpit Trainer - ҉ -    Thread   | Download

Link to comment
Share on other sites

I created a batch file like this to disable the device, start my program, and then enable the device again.

 

In the case of rocksmith as long as it's disabled when the game starts it doesn't detect the pedals and doesn't cause an issue. DCS seems pretty much the same way, though I'm not sure it's universal.

 

devcon disable "HID\VID_06A3&PID_0764&REV_0201"

start "c:\Program Files (x86)\Steam\Steam.exe" steam://rungameid/221680

timeout /t 30

devcon enable "HID\VID_06A3&PID_0764&REV_0201"

 

I then created a shortcut on the desktop and set it to run as administrator since it appears devcon needs administrative rights to go ahead and enable/disable devices.

 

Thanks, this is great.

 

Finally got around to trying this today. But after the game starts and the timeout expires it continues with the rest of the code. So, if I enabled my gamepad, it then gets disabled. I think I need to put a pause in there to stop it. But why don't you have one? Doesn't your device get re-enabled before the game is over?

Intel I9-10850K (OC @ 5.0ghz) │ Asus Maximus XII Hero │ G.Skill Ripjaws 64GB (4x16GB) DDR4 3200 │ Thermaltake Water 360mm
Gigabyte RTX 4090 Gaming OC 24gb │ 2TB M.2 EVO Pro; 1T M.2 EVO; Sandisk SSD Drives │ 49" Samsung Curved Widescreen │ 28" Touchscreen

- ҉ - Blackshark Cockpit Trainer - ҉ -    Thread   | Download

Link to comment
Share on other sites

Yes, but if the controller isn't enabled when the game starts it ignores it. Remove 'start' from before the line to run the game and it will wait, unless its a steam url as above and steam is already running. You can then probably also remove the timeout line.

Link to comment
Share on other sites

Ok, thanks!

Intel I9-10850K (OC @ 5.0ghz) │ Asus Maximus XII Hero │ G.Skill Ripjaws 64GB (4x16GB) DDR4 3200 │ Thermaltake Water 360mm
Gigabyte RTX 4090 Gaming OC 24gb │ 2TB M.2 EVO Pro; 1T M.2 EVO; Sandisk SSD Drives │ 49" Samsung Curved Widescreen │ 28" Touchscreen

- ҉ - Blackshark Cockpit Trainer - ҉ -    Thread   | Download

Link to comment
Share on other sites

One more question. I have been disabling the USB\xxx devices, which sometimes requires me to reboot. I see you only disabled the HID\xxx device. Do you know if those are all I need to disable for any device? I am in the middle of testing bat files... rebooting. over and over to figure out what works best. I'm trying to not have to reboot at all..

 

I have an x55 Stick, x55 throttle (separate usb ports), CH Pedals, x52 Pro, and a Gamepad. So, that's 5 devices.

Intel I9-10850K (OC @ 5.0ghz) │ Asus Maximus XII Hero │ G.Skill Ripjaws 64GB (4x16GB) DDR4 3200 │ Thermaltake Water 360mm
Gigabyte RTX 4090 Gaming OC 24gb │ 2TB M.2 EVO Pro; 1T M.2 EVO; Sandisk SSD Drives │ 49" Samsung Curved Widescreen │ 28" Touchscreen

- ҉ - Blackshark Cockpit Trainer - ҉ -    Thread   | Download

Link to comment
Share on other sites

  • 1 year later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...