WDTF- so easy to use, I must have missed something...
This is admittedly a rework of an earlier (withdrawn) post. But I had occasion to play a bit with WDTF, and it was truly easy, so I've left most of it intact, just removing some out-of-place rants and a couple of typos...
I'll leave the "Now Playing" tags in, although I've not currently got that plug-in- more on that later.
The KMDF serial sample requires you to disable all devices using the serial.sys driver so that the new driver can be installed. We're trying to fully automate this testing (been doing it by hand, but machines never sleep or tire or get bored, and I like to do all of those things).
I had been planning to rip out the code I had in WdfVerifier that found all the KMDF devices affected by a change in settings and disabled and then enabled them, then changing it to do this task, but that seemed like an overly special-purpose piece of code to add to the maintenance load. Then I thought, "well maybe WDTF can do it", so I started on that approach by reading the WDK info on WDTF.
Now Playing:Grateful Dead - Reckoning [Bonus Tracks] Disc 2 - It Must Have Benn the Roses [Alternate Live Version][*]
Now of course, I have never used WDTF before, and I don't claim to know anything about scripting languages or even C# for that matter [although in my more cynical moments I look at the list of programming languages I already mastered to some degree and wonder "just why the heck is it I have to prove that I can do it again after so many times"]. But let's see:
Now Playing:BoA - BEST OF INUYASHA ? - Every Heart-???????-
Now Playing:Various Artists - Halo: Combat Evolved [Original Soundtrack] - What Once Was Lost
I began with maybe 10 to 15 minutes of reading WDTF documentation in the WDK. Now, to be fair, I've done that before to answer questions. Still, the query capabilities made it look simple- find all the devices with serial.sys as their driver, get the device management interface on them, and disable or enable them. About as close to a 1-to-1 mapping to the original problem as I could envision. So let's give it a whirl...
First, I ran the batch file to install WDTF on my dev box. Took about 5 minutes, because I wasn't in much of a hurry. Perhaps I was cheating- I did have the WDK already installed [but I have code of my own in there, I ought to get some slack cut for me in this instance]. I had to do it twice, because the first time I didn't run from an elevated command prompt.
Now Playing:Field OF View - Memorial Best Disc 1 - ?????
Then, I ran the enumdevices sample script untouched. Just to be a clown, I tried it from an unelevated prompt first. What a surprise, I had to elevate.
Now Playing:Various Artists - Halo: Combat Evolved [Original Soundtrack] - Ambient Wonder
Now Playing:Grateful Dead - Steal Your Face! Disc 2 - It Must Have Been the Roses
(Good thing I always liked that song- shuffle does some interesting things from time to time- but there is a fair amount of overlap in my Dead library).
I then opened Visual studio, opened the enumdevices script file from it, and pasted the Vbscript code from it into a fresh source file. Changed the query and ran it.
Script didn't like the hardware IDs [suspect it ran javascript when I ran the raw WSF file]- most likely a mismatch between string and array of string variants. So like I care? I disabled it, and got a summary of two devices. I have two COM ports, so simpleton that I am, I'm satisfied.
I then got totally lazy and just tried to call Disable and Enable on the ITargets it was enumerating.
Oops, now that wasn't such a bright idea, was it.
Now Playing:??? - ????????????????????????ยท???????? - Who will save
(I know this is a Yoko Kanno orchestral work from the sound of it [and the fact it's in my library, anyway]- might be Escaflowne, but I don't track them all).
Now Playing:Yoko Kanno - Wolf's Rain - Visions of a Flame
Broke to do some real work for a bit there- more YK is cool, tho...
Now Playing:Martin ODonnell - Halo 2, Vol. 1 - Remembrance
(As is Mr. O' Donnell) ANYWAY, I then went back for another couple of minutes of documentation and find that I just need to get the DeviceManagement action interface from the target, and the code for that is of course breathtakingly complex (NOT).
Now Playing:The Grateful Dead - Workingman's Dead [Bonus Tracks] - Mason's Children [Live][*]
I run device manager in one Window and my new script (named breakfast.vbs because it plays with cereal drivers, of course) in another. Amazing- it works. I'm done already- must have taken all of twenty minutes to use an unfamiliar package in a programming language I'm barely competent in to perform a complicated enough task I've already spent more than twenty minutes answering questions about it.
So, "what the hey", I figure- might as well blog about it so I can pretend I did something earth-shatteringly useful that morning. Now, if I was really ambitious and wanted a multi-week project, I'd try using voice input or something, but I think I answered my initial question properly in the title for this post.
Now Playing:The Grateful Dead - Workingman's Dead [Bonus Tracks] - High Time
Oh, and here's my final script, in all it's glory...
Now Playing:The Grateful Dead - Workingman's Dead [Bonus Tracks] - High Time
Now Playing:Grateful Dead - Europe '72 [Bonus Tracks] Disc 2 - Looks Like Rain [*]
' Let us find out just how hard it is to find all devices using the serial driver in WDTF, disable and enable them
' This is about 3 or 4 changed lines from the enumdevices sample script in the WDK. You user mode guys got it so easy...
Set WDTF = WScript.CreateObject("WDTF.WDTF")
Set Devices = WDTF.DeviceDepot.Query("Service='Serial'") ' I figured out that query all by myself, I be so proud:)
For Each Device In Devices
' echo info on all devices found
WScript.Echo "DeviceID: " & Device.GetValue("DEVICEID")
WScript.Echo "DisplayName: " & Device.GetValue("DisplayName")
WScript.Echo "SymbolicLink: " & Device.GetValue("SymbolicLink")
WScript.Echo "Class: " & Device.GetValue("class")
WScript.Echo "Drivers: " & Device.GetValue("drivers")
WScript.Echo "ClassGUID: " & Device.GetValue("ClassGUID")
WScript.Echo "Enumerator: " & Device.GetValue("Enumerator")
' WScript.Echo "HardwareIDs: " & Device.GetValue("HardwareIDs") Guess arrays don't work out so well here.
WScript.Echo "CompatIDs: " & Device.GetValue("CompatIDs")
Set ISoOwnThisPort = Device.GetInterface("DeviceManagement")
WScript.Echo "Disabling it..."
ISoOwnThisPort.Disable
WScript.Echo "Enabling it..."
ISoOwnThisPort.Enable
Next
WScript.Echo "Found " & Devices.Count & " cereal devices"
WDTF.Destroy()
Now Playing:Seatbelts - Cowboy Bebop - Cat Blues
To think that people even get to charge for that kind of work... Oh well, my apologies to those I've upset by my not taking my craft seriously enough...
Got some Bobby to listen to, so it's time to post and forget... Besides, there's lots of real work to get to- far too much playtime today...
Now Playing:Grateful Dead - Dead Set [Bonus Tracks] Disc 1 - Little Red Rooster
Decided to do some final edits, so now I've got this little acoustic gem for my reward:
Now Playing:Yuki Kajiura - Madlax, Vol. 2 - Complicated
But another Bobby favorite follows (I so like this job, even if I have to wear headphones after about 9 AM):
Now Playing:Grateful Dead - Dead Set [Bonus Tracks] Disc 2 - Let It Grow [*]
At this point in my original post (as long as I'm describing what I listened to that day, I'll note I've got "Casey Jones" now, so I hear "Trouble Ahead- Trouble Behind" as I write this), I diverged into some ranting. Instead I'll now drop a hint- these posts have been coming from LiveWriter [of course], but the OS I'm using isn't going to ship for a couple of years yet. Yes, some of us start using them that early in the cycle so we can find the bugs early... And No, that was not what was making me rant way back when... So the reason the Now Playing plugin isn't active is I periodically refresh the OS, occasionally from scratch [other times as upgrades], and I don't always find the time to drag in plug-ins- besides while it was a fun experiment, it's messy.
Instead I got around to trying the IM box on the sidebar [still wrestling with CSS to widen it, though ;<).
I finished that post listening to one of many gems, so I'll just wish that's what I'm doing now (actually, I've got a song queued up from my brother Jim's band UberSonik [he recycled the name for his company]- bet he still doesn't know I listen to his stuff pretty much every day I'm at work):
Now Playing:Grateful Dead - Europe '72 [Bonus Tracks] Disc 2 - Morning Dew