Saturday, December 11, 2010

Properly Winterizing External Hose Bibs

Hey, do you know what a new Yamaha YZF-R6 sport bike and failing to winterize external hose bibs properly have in common?  They both cost me ten thousand dollars.  Yeah, the sport bike purchase was more satisfying...and had better resale value.




Well, now I know better...and I have decided to save you the cost of one chick magnet.  Okay, to be fair, my wife referred to it as my mid-life crisis machine...but she is a chick...and she married me while I owned it, so I rest my case.

In climates in which the winter temperature drops well below freezing, most homes are now constructed with frost-free hose bibs.  Such a valve extends for about a foot into the home and drains that one foot extension when the water is turned off.  Prior to installation, they look like this:

A couple of years ago we took advantage of the real estate downturn to upgrade to a larger home that was equipped with such modern marvels.  As the cold weather approached, we turned off the water supply to the external faucets and settled in for the winter.  When Spring arrived, we turned the water back on and spent a nice day in the yard gardening...while our finished basement flooded.

So what did we do wrong?  Well, it wasn't entirely our fault - the pipes were angled incorrectly and a particularly cold winter did us in.  That said, we learned much that year from our plumber, so I am passing it on as I watch the mercury drop.



Step 1 - Disconnect your hoses

This is the one step that folks often forget to perform...and it is the primary reason that supply pipes to external hose bibs break.  You can turn off the water at the supply valve for the bib, but if your hose is still connected to the faucet, you are done.  The faucet cannot drain with the hose connected.



Step 2 - Disconnect your hoses

Seriously, our plumber puts his kids through college on this one. His words.



Step 3 - Turn off the water supply for the bib

The bib's water supply control valve is located somewhere in a heated portion of your home.  If it has a round wheel, turn it clockwise until it will not turn further.  If it is a lever, turn it one quarter turn.



Step 4 - Go back outside and open the faucet

This step allows the water in the pipe to drain...or at least some of it.  If water keeps flowing, you didn't turn off the supply valve properly.



Step 5 - Open the bleed screw on the water supply control valve

Go back to the water supply control valve and look for a small screw on the valve.  This should be the air bleed screw.  Remove the screw to break the vacuum on pipe, which will allow the rest of the water to flow out of the external faucet.  Note, some water will also come out of the bleed screw hole...so have a bucket handy.  After several minutes, replace the screw.

Caution:  If the original plumber installed your valve backwards (which was the case in my house), the bleed valve will be on the supply side.  If that's the case, water will shoot out of this bleed valve at house pressure...and will not stop...until you put your finger over the hole and scream like a little girl for your wife...while your finger feels like it is being stabbed with a knife.  Fortunately, my daughter could not find her video camera at the time.

Such an improper installation should be rare, but just to be safe, ensure that you have someone standing by next to the home's main water supply valve the first time that you remove these screws...and make sure that you also have a large bucket handy...just in case.



Step 6 - Close the external faucet

No need to let the cold air come into the pipe during the winter.



Step 7 - Insulate external faucets

This step may be overkill, but after you have been up to your hips is soggy drywall, it seems like a nice bit of added insurance.  You can get Styrofoam freeze covers at your home supply store for just a couple of dollars...and they look like this:




Final Words

If you have any doubts, call a plumber and have them help you winterize your hose bibs the first time that you attempt it.  Sure, that option may sound expensive...but I guarantee you that you will wish that you had done so if things go wrong in the Spring.

On that note, when you do turn the water supply back on in the Spring, do so with all faucets closed...and then listen near the valve for the sound of running water.  You should hear some noise briefly as water rushes into the pipe and compresses the air, but the noise should stop fairly quickly.  If it is constant and your faucets are closed, turn off the water supply quickly...and call that plumber.

cheers,
Scuba

Friday, December 10, 2010

Enabling and disabling USB devices with a simple Windows shortcut

I was asked recently if there is a straightforward way to enable and disable a USB device on the fly without having to unplug the device or navigate through the Windows device manager.  Sure, one could use the Windows system tray application to eject the device, but what then do you do when you want to re-enable the device?

The classic example (at least for my gaming nerd friends) is a USB headset.  On most days I'd prefer to drop the headset and lay waste in Call of Duty with the sound pumping out of my speakers...rattling the windows while I swill back Diet Coke and laugh maniacally.  Then, my wife gets home and shakes her head as she searches her memory for any vague inkling of why she found me attractive initially.  That's when the headset gets plugged back in.

This constant unplugging and plugging of the headset is not exactly difficult, but it is a bit annoying...especially when one realizes that you are being required to perform a physical action to reconfigure the computer.  It's a computer, right?  They store recipes and guide rockets.  Why the heck can't I just tell it, "use the headset now sparky, I can't afford another divorce."  Why isn't there a way to do this by just, for example, selecting a link in the Windows Start menu?

Well, there is...and I have the secret...in 25 easy steps.  Okay, it may be a tad simpler, but not much...but if you are the adventurous type and want to know how, read on.  My example will be based on creating this capability for a Logitech G35 headset since I am writing this article for folks in the Logitech forums, but the method should be applicable to any USB device...including that USB-powered "massage wand" in your desk drawer.  I am also assuming that you are running Windows 7.  If you aren't, you are missing out...and will need to adjust related steps accordingly.

Okay, here goes.

Let's start with our eye on the prize.  This is the goal:




As you can see in that picture, I have two links in my Windows Start menu to enable and disable my headset.  When I select one of these links, a script runs and makes it so.  No UAC security prompt, no reboot, no fumbling with cables.  Hey, that's why you are here...so you knew it was possible.  Well, this is how you do it...



Step 1 - Download devcon.exe ...from somewhere

Devcon is an application distributed freely by Microsoft and which allows command line-based control of, amongst other things, USB devices.

http://support.microsoft.com/kb/311272

Hey, you didn't think that I was doing this on my own, did you?  The first rule of good software development is "don't reinvent the wheel"...so I'm not, I'm stealing someone else's.

The trick is finding the correct version of this program.  For years, the 32 bit version of Devcon (which is readily available from Microsoft) was fine for most of us. Of course, many of us are now basking in the glory of 64 bit Windows 7 goodness...and the 32 bit version of Devcon will not work for that 64 bit OS.  Instead, we need the 64 bit version, which Microsoft now makes available as a component of the Windows Driver Kit (WDK)...packaged conveniently in a 700 MB ISO disk image.  Nice.  Thanks.


Okay, well this is where we separate those who will be able to follow the instructions in this article from those who were going to trip on one of the later steps regardless - go fire up Google, find whichever version of Devcon is appropriate for your OS (32 bit or 64 bit), and download it.  Sure, Microsoft is a good source, but there are...ahem...alternative mirror sites that provide direct access to the smaller 70 KB devcon.exe application.  That's all it is by the way - an application.  There is no installer.


Go ahead, go Google...I'll wait.


Back?  Great. Let's keep this simple.  Start by creating a folder called "bin" at the root level of your C drive,  creating a folder called "headset" in that "bin" folder, and placing devcon.exe in that "headset" folder.  Okay, call it what you want it and put it wherever you want, but these instruction will assume this directory structure.  The result should look something like this:





Step 2 - Determine the ID of your USB device

Open a Windows "Command Prompt" window with elevated permissions.  Okay, if that statement didn't make sense, you may just want to stop here and just come to terms with needing to plug and unplug your device physically...because I am assuming some level of nerd skill...but just this once, I'll hold your hand.

Open the start menu, place your cursor in the "Search programs and files" text box, type "Command Prompt", right-click on the matching item, and select the "Run as Administrator" option.  That taste was free.  The next one will cost you.

Actually, you don't need elevated permissions for this step, but you will need them later, so let's keep it simple.

Now use your DOS syntax knowledge to "CD" to your new "headset" directory.  i.e., cd \bin\headset ...and then execute the following command:  devcon hwids usb* > usb_device_ids.txt

The result will be a new file in your "headset" directory named usb_device_ids.txt

Okay, this is where we separate the nerds from the guys with girlfriends.  Open that file in a text editor and scan for the name of the USB device that you want to be able to enable and disable with a single-click.  Since I am focusing on a Logitech G35 headset, I am looking for a device whose name looks somewhat similar...and I found it:



That's Notepad++ by the way - a fantastic freeware text editor, but any text editor will do...even the standard Windows Notepad.

Okay, after you find your entry, locate and copy the longer of the two "Hardware ID's".  In my case, that is:

USB\VID_046D&PID_0A15&REV_0303&MI_00

By the way, why the term ID's in that file has an apostrophe is beyond me.  Someone at Microsoft needs to read Steve's Bible .

That hardware ID is the value that we will use in subsequent scripts to specify to Devcon which hardware device that we wish to control, so if you grabbed the wrong ID, life is not going to be so good for you as we move on.



Step 3 - Create scripts to disable and enable the device

Fire up your text editor again and add the following line to a new text file:  devcon enable "USB\VID_046D&PID_0A15&REV_0303&MI_00"

...substituting your device ID for mine.  Save the file in your "headset" folder, naming it enable.bat

Create a second text file named disable.bat that contains the following line:  devcon disable "USB\VID_046D&PID_0A15&REV_0303&MI_00"

...once again, substituting your ID for mine.



Excited?  Don't be.  We are far from done...but at least we can test.

Note:  If you aren't placing devcon.exe in the same directory as these scripts, your batch files will either need to "CD" to the devcon.exe location before running the above commands or you will need to modify your system PATH variable to include the location of devcon.exe.  Thanks to Oblivion1810 for noting that issue.



You now have two batch files that you can use to enable and disable your device.  Unfortunately, they will only work when you execute them from a Command Prompt window with elevated permissions.  You can't just double-click them, nor can you right-click on them and select "Run as Administrator."  Neither approach will work.  No worries...we'll solve that problem later, but given that we have a Command Prompt window with elevated permissions, we can test them.

One word of caution - if you are running software that is "using" or "controlling" your device, the scripts won't work.  For example, my Logitech G35 ships with software that runs in the system tray and is used to configure it.  If that software is running, the scripts will not work.  Well, actually they do work, but require a reboot...which is hardly convenient.  Thus, I have disabled that program.  If you have a G35, you can do so temporarily by right-clicking on that application in the system tray and selecting "Exit."  Unfortunately, it will come back after you reboot.  If you want to avoid that hassle, Google msconfig to learn how you can disable it permanently...or at least until you decide to re-enable it.

Okay, assuming that you have solved that issue, we are ready to test.  First, make sure that your headset (or other device) is connected and functioning.  Next, in the Command Prompt window that we opened earlier (with elevated permissions), enter the following:  disable

If all went as planned, your device is disabled.  Try testing it.  If it is headset, check to ensure that your computer's sound is now coming out of your speakers.  It's not?  Check the volume control...and if that isn't the problem, you may need to start shutting down applications.  Why?  If an application is using your audio drivers, the script cannot disable the sound device.  Such applications include games and, believe it or not, your browser.  Yes, your browser.  Blame Flash.  If you visited a site with Flash in your current browser session, the Flash plugin is probably still loaded in the background and will prevent disabling your sound device...at least in this manner.  Thus, if the disable device script didn't seem to work, try shutting down applications and then trying again.

If you have shut down all of your applications and disabled any device-specific system tray applications and the disable script still doesn't work, you may need to go back to the prior steps and see if you downloaded the wrong version of Devcon, copied the wrong hardware device ID, or missed some other critical step.  If, on the other hand, the script did work, fantastic.  Now test your enable.bat script and ensure that the device is enabled once again.  If so, we are ready to deal with the need to execute the scripts from an elevated permission Command Prompt window.

By the way, if you are still using Windows XP, skip directly to Step 6. Yes, good news!  No UAC = an easier (and riskier) life!



Step 4 - Create Windows Scheduler Tasks

This approach seems bizarre, but it not only works, the strategy is recommended by many sources to bypass UAC prompts for Windows shortcuts...so have a little faith.

Open the windows Task Scheduler by opening the start menu, placing your cursor in the "Search programs and files" text box, typing "Task Scheduler", and selecting the matching result.

This window will open:


Of course, the tasks in your window will depend on your system.

Next, we need to create a task for the enable function.  Don't worry, it won't be a scheduled task.  Instead,  we will create a task that only executes when we instruct it to run...and to run with (wait for it) elevated permissions.

Under the Task Scheduler's "Actions" menu, select the "Create Task..." option.  You will then see a window that looks like this:


Enter the following values into the indicated fields on the "General" tab...leaving all other fields set to their default values:

  • Name:  Enable Headset
  • Run with highest privileges:  checked

The result will look something like this:




Now switch to the "Actions" tab, click the "New..." button, and enter the following value into the indicated field...once again, leaving all other fields set to their default values.::

  •  Program/script:  C:\bin\headset\enable.bat

The result will look something like this:



Click the "OK" button and you will then be back on the "Actions" tab, which should look something like this:


Click the "OK" button to complete defining your Enable Headset task...and then rinse and repeat to create a Disable Headset...pointing the "Program/script" value to your disable.bat script.


We can now test the tasks to ensure that they work.  To do so, click on the "Task Scheduler Library" item in the Task Scheduler's left-hand navigation pane.  You should now see a list of all tasks defined on your system:


Next, click your "Enable Headset" task and select "Run" from the application's right-hand command pane.  Verify that your device is enabled...and then "Run" the "Disable Headset" task...to verify that your device is now disabled.

Note: If it doesn't seem to work reliably, you might try pausing for a brief period between invocations...because while you could slam USB enable commands at Devcon under Windows XP, it seems to be somewhat more sensitive under Windows 7...at least on my system with this specific headset.

If things worked as planned, you are much closer to those two icons in the Windows Start menu.



Step 5 - Create scripts to call the tasks

It's time to create two new batch files, which will call the tasks that you just created. Open your text editor once again and add the following line to a new text file:  schtasks /run /tn "Enable Headset"

Save the file in your "headset" folder, naming it Enable Headset.bat


Create a second batch file named Disable Headset.bat that contains the following line:  schtasks /run /tn "Disable Headset"


You should now be able to double-click on each of these files from Windows Explorer to enable and disable your headset (or other device).



Step 6 - Make it pretty

The next step is to create a custom icon for each batch file.  The easiest way is to accomplish this goal is to create a Windows shortcut to each batch file and then change the icons for those shortcuts.

To change a shortcut's icon, right-click the shortcut, select "Properties", and then click the "Change Icon..." button.  If you are not sure where to find a decent icon, it's Google time again.

You are now ready to add the two commands to your Windows Start menu, which you can do by holding down your Shift key while right-clicking on each shortcut and then selecting "Pin to Start Menu."



Yeah, the process should be easier.  This is the point at which someone posts a comment that points to a freeware utility that provides this capability.  I hate that person.

cheers,
Scuba

First !

Okay, granted, that's cheating.


Welcome to Scuba's Random Musings.  I'll warn you in advance, this blog will have almost no browsing value.  Yes, you somehow found this dark narcissistic corner of the internet and I am already trying to turn you away.  What can I say...I'm not in marketing.

No, this blog will not comprise a cohesive set of articles focused on a specific niche or agenda, nor will it focus on every tweet-able aspect of my fascinating life.  Instead, I have decided to create a place to post items of general interest on whichever topics happen to be on my mind.  I'm an engineer and software type, so I assume that most items will tend toward the nerdy...but who knows?  I have also worked as a bartender, soldier, firefighter, short-order cook, and paperboy...so I may drift.

You have been warned.  Prepare for epic boredom.

cheers,
Scuba