I like to play Fallout 3 which is very buggy normally, and even more so once I've added some mods. Needless to say, it crashes a lot. I can deal with the crashes, the only problem is when it does my sound card gets caught in an endless loop-style playback.
I can stop the looping audio by toggling the device on and off in Device Manager (Disable/Enable), although it's annoying to have to go into Device Manager all the time. So I'm hoping to semi-automate the process.
Is there a way to toggle a device on and off using a batch script? That way I could just place it on the desktop and run it when my sound card starts looping.
Answer
Thanks to the link provided by and31415, I was able to McGyver a solution, using the Device Console (DevCon) utility.
I've copied the instructions for how to get the tool from this answer:
DevCon is a command-line tool that displays detailed information about devices, and lets you search for and manipulate devices from the command line. DevCon enables, disables, installs, configures, and removes devices on the local computer and displays detailed information about devices on local and remote computers.
Download the appropriate
.cab
package depending on the operating system:Open the
.cab
archive and extract the file namedfil[some letters and numbers]
. It should be about 80 KB.- Rename it to
devcon.exe
.
Using this tool, I was able to figure out what the Hardware ID was for my soundcard, and use it to enable and disable the device. Seeing as I simply need to toggle the device, My Batch file simply looks like this:
devcon.exe disable "PCI\VEN_13F6&DEV_8788&SUBSYS_85221043"
devcon.exe enable "PCI\VEN_13F6&DEV_8788&SUBSYS_85221043"
That longish string is the Hardware device ID. To find this, I used DevCon's findall
command, piping the output to a text file for easy searching.
devcon.exe findall * > C:\output.txt
Searching for my device name, I copied the string that I needed.
Note: Unfortunately, the batch still requires Administrator Privileges to run, but that's a small issue (and one I may be able to solve at a later stage). But for now, this works for me.
No comments:
Post a Comment