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

I know there are programs that do the job much better but I like it the dirty way: batch files.
It’s fast, no installation required and does what I want. Enough talk, here is the code:

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

Copy the code to a text file and change its extension to .bat
/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.