Category Archives: How-Tos

How to disable & enable a network adapter on Windows with PowerShell

Sometimes my USB wireless network adapter doesn’t work at all after Windows 7 recovers from sleep mode. I haven’t found the root cause of this problem but disabling & enabling the adapter works well as a workaround. Here is a PowerShell script to do so:

# Get the network adapter object
$adapter = Get-WmiObject -Class Win32_NetworkAdapter |
    Where-Object {$_.Name -eq "TP-LINK Wireless USB Adapter"}
# Disable it
Write-Host -nonew "Disabling $($adapter.Name)... ";
$result = $adapter.Disable()
if ($result.ReturnValue -eq -0) {
    Write-Host "Success.";
} else {
    Write-Host "Failed.";
# Wait 2 seconds
Start-Sleep -s 2
# Enable it
Write-Host -nonew "Enabling $($adapter.Name)... ";
$result = $adapter.Enable()
if ($result.ReturnValue -eq -0) {
    Write-Host "Success.";
} else {
    Write-Host "Failed.";

Make sure the adapter name on line 3 matches what you have in Control Panel > Network and Internet > Network Connections. Mine is called "TP-LINK Wireless USB Adapter".

Since you will need to run that as an Administrator, create a shortcut to the PowerShell executable and pass the full path of the script above as an argument. Then, open the shortcut properties, click on "Advanced…" and check "Run as an administrator".

Update: This method only works on Windows Vista and above.

Update 2: I have not encountered this issue since I've updated to Windows 8.

How to get a c cedilla on Ubuntu

I was getting really frustrated with the fact that I had to copy and paste the character ç whenever I had a conversation with someone from Brazil. I did a search around the Ubuntu forums to realize that I was not the only one having this problem. The thing is that on Windows, when you type single quote and c, you get a c cedilla (ç). On Ubuntu, you get a c acute (ć).

If you are in the same boat, here is how I solved my problem.

  1. Add “U.S. English International (with dead keys)” to your list of layouts (System > Preferences > Keyboard).
  2. On the Layout Options tab, make sure the Alt key is a third level chooser.
  3. Alt+, gives the desired results.

How to get a directory listing on Windows using batch files

Here is a quick and easy way to get a directory listing on Windows with a batch file:

@dir %1 /w /b /o:gn > "_listing.txt"

Paste the code in a text file, save it and change its extension to .bat. Run it on the directory where you want to get the listing.

Flags Explanation
/b Bare format, remove this for detailed info
/o:gn > "_listing.txt" Sends the output to “_listing.txt”

For further customization, type dir /? on a command prompt.