Windows 7

A 3-post collection

Solution: WUSB54G network adapter disconnects on Windows 7 (64-bit)

There is an issue with the WUSB54G network adapter on Windows 7 (on Vista as well I think). It could only be present on a 64-bit OS, I don't know. The Wifi connection will repeatedly drop, and many times the adapter will completely disappear from device manager, as if it has been unplugged. The only thing to be done is to unplug and replug the adapter.

It seems like a power management issue, but the Power Management tab on the adapter properties in device manager doesn't help. Nor does adjusting USB Selective Suspend in Power Options.

The solution is to install the RT2500USB driver from Your device will now appear as an RT2500.

1 Feb 2011 The problem was insufficient power reaching the USB device. It didn't help that I was using a long, light-up cable, plugged into the front panel of my computer. I moved the plug to a powered USB Hub, reverted the driver, and have had no problems since.

If still having difficulties, try running WLAN Optimizer, perhaps even in streaming mode. Vista was notorious for a terrible background scan lag spike every 60 seconds, which while drastically reduced in Windows 7 doesn't seem entirely gone.


SSH on Windows 7 continued: charade, ssh, rsync, Unison

16 May 2011 Updated and polished.

In the previous article we established an SSH session with KiTTY. However to take full advantage of Cygwin and SSH it's equally important that your Windows client can connect with Cygwin's ssh.

As Pageant handles authentication for KiTTY, so ssh-agent authenticates for ssh.exe.
But we're on Windows! We like KiTTY, and Pageant has a nice interface, it should be all we need.

Charade is an ssh-agent in Cygwin that proxies requests to Pageant.

Client instructions (Windows-centric variation on keychain)

  1. Install Cygwin and hstart and configure environment variables on the client as done previously on the server.
  2. Compile Download charade.exe
  3. Drop it in C:\cygwin\bin
  4. Add another program start action to our Pageant entry in Task Scheduler.




    /noconsole "bash -c "charade > ~/.ssh-agent""

    Move this entry up, before Pageant's start action.

  5. Append source ~/.ssh-agent to the end of C:\cygwin\home\<user>\.bash_profile
  6. Run task, launch local Cygwin shell, connect to your server: ssh <hostname>. Hooray!

With charade operational, we can use rsync and Unison over SSH. Awesome!
Remember when we exported our private key in OpenSSH format (no file extension)? That's the one ssh.exe requires.

Here's an example bash script for pushing changes over a LAN with rsync that handles spaces in filenames.


# escape spaces in file paths
# (the escapes won't be visible if you echo... you'd need to triple escape... which we don't want)
src=`cygpath $2`
src="echo $src | sed 's/ /\\ /g'"
src=`eval $src`

if [ $# = 2 ]
    dest=`cygpath $3`
    dest="echo $dest | sed 's/ /\\ /g'"
    dest=`eval $dest`

source ~/.ssh-agent

# rsync
# -a, archival mode, does:
# -r (recursive)
# -l (copy symlinks as symlinks)
# -p (preserve permissions)
# -t (preserve modification times)
# -g (preserve group)
# -o (preserve owner)
# -D (preserve device & special files)
# -v, verbose
# --delete, delete extraneous files from destination dirs (DANGEROUS)
# --rsh, the remote shell to use
# -z, compress file data during the transfer

# ssh
# -a, disables agent forwarding
# -x, disables x11 forwarding
# -c, set the cipher specification (blowfish being the quickest)

#LAN rsync:
rsync -s -av --delete --rsh="ssh -ax -c blowfish" "$src" $receiver:"$dest"
#WAN rsync:
#rsync -s -avz --delete --rsh="ssh -ax" "$src" $receiver:"$dest"

I call the script from within my text editor like this:

cmd /c bash ~/ Chris-Laptop 'C:\abc\some_source_dir' 'C:\some_dest_dir'

(Or 'C:\abc\source_dir\' 'C:\abc\dest_dir\', or just a single 'C:\abc\source_dest\' if the path is equivalent at the destination.)

It's important to understand the distinction of a trailing slash on the source folder with rsync (especially with --delete). Back up your data before experimenting.


Windows 7 solution to "My Documents" pollution

I have 26 folders in my My Documents folder. Do you know how many of those I intentionally created myself? Nope, lower. Okay, I'll tell you: zero. Applications dump their garbage in there like crazy, and it's annoying as hell, I thought this was where I put my documents! Windows is designed for users to save here, they've made it quite convenient. If only it wasn't so damn polluted!

I'll be honest, when I first saw Libraries in Windows 7 I thought, "Uh oh." Then after hearing Joel Spolsky talk about it on this Stack Overflow podcast I thought, "Oh no."

Well guess what? Libraries in Windows 7 might actually be quite the clever and elegant solution to User Space Pollution, and that, my friend, is a very good thing.

It's simple really, the Common Dialogs of Windows 7 (open/save file…) are designed for conveniently saving to libraries in general now, and no longer My Documents.

common dialog

So the solution is simple. Create a new folder in %UserProfile% (that's C:\Users\<Name>), and name it something like Own Documents. Now click on your Documents library, and then where it says "Includes: x locations". Add your new folder, and right click it and set it as the default save location. I strongly recommend removing My Documents from the list entirely.

Documents library as 'Own Documents'

Applications don't use the library interface, they will pollute My Documents specifically, and you no longer have to see it! Furthermore, the Documents library will now point to and hold your actual own documents. Eureka!