Category Archives: windows

how to stop windows 10 from rearranging your desktop icons

I’m a desktop minimalist myself and the trashcan is about all I want to see on my desktop. However if you like your desktop with lots of icons on it, arranged according to some non-alphabetical grouping system you might find out that Windows sometimes rearranges them nicely in alphabetical order, aligning them all nicely to the top left of your desktop without your prior consent.
This typically happens after reboots, switching between resolutions, plugging and unplugging a secondary screen or docking/un-docking the laptop.
It can drive people mad.

This seems to be an issue that has been plaguing Windows 8 and 10 for quite a while already, driving lot’s of people bonkers. Unfortunately when looking for a solution online in various fora you tend to find a lot of useless tips or the suggestion to install some third-party desktop icon position-saving software. Eew.

There is a simple solution in the Windows settings however, but I have to admit it’s not very obvious and I had to look for it quite a bit to find it.

It’s all in the settings as expected, but it’s spread out in two different spots, which makes it hard to get right.

Here’s how to fix it:

1. Right click on your desktop and disable the auto arrange feature by disabling the checkbox next in View > Auto arrange icons.

Shows how to disable the auto arrange icons feature in Windows.

You’d think that should do the trick right? Well most people do. But there’s another option that interferes with your desktop icon zen garden staying the way you want it.

2. Right click again on your desktop, now click Personalize.
You’ll see the Settings screen appear.
There you select Themes.
Now click Desktop icon settings.
Now look what we have there. A checkbox labeled “Allow themes to change desktop icons“.

Uncheck it and press OK.

You should now no longer experience the frustration of computer code messing with your desktop icons.

Zen at last.

Disable the Allow themes to change desktop icons checkbox

 

class not registered error in PowerShell on commandlet

I ran into this weird COM component error trying to run a commandlet from an IIS administration module.

Retrieving the COM class factory for component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6}
 failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_
 CLASSNOTREG)).

The module imported fine and I could list the available commandlets and get help on them. So everything seemed to be installed properly. It just turned out that I was running the command on the wrong platform.

Or to be more exact, I ran the command in a 32-bit mode Powershell instance while I should have been in a 64 bit version. The COM component that was called is a 64 bit one, and that didn’t sit well with the 32-bit Powershell instance.

So how do you see what version of Powershell you’re in? Find out by running this statement , which returns true or false:

[Environment]::Is64BitProcess

Now that you know what mode you’re in, try the other one. You should have both in your Start Menu, where the 32-bit one has (x86) appended to the name. In my case that did the trick.

Windows search results for Powershell shows all versions available of the PS shell.

 

erase free space on an SSD drive

DeleteAs you probably know (because you’re reading this post) Windows doesn’t really destroy a file when it is deleted. It merely removes the references in the file table so you don’t see it in on the file system anymore. But the file is still intact sitting there on your hard drive until some other file is written over it.
If you want to truly erase those files on a HDD drive you can use a number of tools to erase the free space on the drive. What these tools do is simply overwrite all free space with random data and thus effectively overwriting and destroying those deleted files still sitting intact in your free disk space.
Free tools that can do this are the command line Secure Delete tool from System Internals and the handy CCleaner (see the tools menu).

For an SSD drive however overwriting the free space with random data is bad for your drive. SSD’s have a limited number of times you can write data to their blocks. Using a random data overwrite tool, which can even end up do this multiple times, is just a bad idea.

Luckily everything is built into your SSD drive to do this automatically. It’s called the TRIM function and from Windows 7 on this is activated by default so normally you don’t have to do a thing to take advantage of this secure-delete feature.

However if you are like me then you want to be sure if this feature is activated.
On Windows, you can do this by opening a command prompt and entering the following command:

fsutil behavior query disabledeletenotify

If you get the following, your TRIM command is already active on Windows:

NTFS DisableDeleteNotify = 0

If this would return a value of 1, you can activate the TRIM function with this command:

fsutil behavior set DisableDeleteNotify 0

You can find more detailed instructions and information about activating the TRIM function here:
How to check if TRIM is enabled on your SSD and how to enable it
Why SSD TRIM support is so important and how to enable it

And then there’s always Google of course.

Photo by Delete, cc-licensed.

verifying an md5 file hash with just powershell

Tools
You see this possibility for a lot of software downloads but if you’re like me you hardly ever end up doing it: verifying an install file’s MD5 or SHA-something hash.
For Open Source software this is however recommended if you aren’t downloaded from the official mirror (and even then) and certainly if it’s anything related to security (like Keepass for example).

But to verify that MD5 hash you probably need to install yet another piece of software you’re hardly going to need, so you end up not bothering at all.

Hold on a second.

If you have a recent Windows system with PowerShell installed, you probably have all you need to verify that MD5 hash.

Try this in the PowerShell command prompt:

Get-FileHash .\KeePass-2.30-Setup.exe -Algorithm md5

It should print out something like this:

Algorithm       Hash
---------       ----
MD5             CD430EB0F108BB192D2155C68EB7BB48

Which happens to be exactly the MD5 hash code listed on the site for that version of the Keepass installer. Yay!
Without that -Algorithm parameter it prints out the SHA-256 hash by default, but that’s longer and harder to compare visually even though it’s more precise.

That was easy and required no additional software.
Pretty damn sweet.

Photo by Julien Dumont, cc-licensed.

how to move an unreachable window on windows 7, 8 or 10

arrowsOn the “good” old XP this required some trickery and knowledge of window specific shortcuts, but on more recent version of Windows this has become really easy to do.

So if you run into a situation where an application’s window is outside your visible area, because you disconnected a second screen for example and the app doesn’t automatically snap to the only screen left, simply do this:

  • Keep the Windows key pressed and hit the cursor key left or right.

Your window will simply snap back to your current screen and all is well.
Using it with the up & down arrow will maximize or minimize the active window. Always handy to know those shortcuts if you have both hands on the keyboard anyway.

Photo by Dean Hochman, cc-licensed.

find and delete duplicate files with just Powershell

... analog computer!

Consider this. You have the same files with different file names spread out over a bunch of folders. If you are on a recent Windows machine, Powershell is all you need to get out of that mess and delete the duplicates.
This also means you get to do this from the command line which makes it extra l33t.

Cool. Let’s get started.

ls *.* -recurse | get-filehash | group -property hash | where { $_.count -gt 1 } 
| % { $_.group | select -skip 1 } | del

Bam!
You’re done.

Alright. Here’s what going on in detail:

ls *.* -recurse             # get all files in the current folder and all subfolders
get-filehash                # calculate the file hash for all files
group -property hash        # group them by the hash value
where { $_.count -gt 1 }    # select those groups with more than 1 item
% {                         # for all groups
    $_.group |              # output the group content, which are the files
    select -skip 1          # select all but the first file 
   }                        # (we don't want to delete all of them right?)
del                         # delete the file

If you want to experiment with this I’d recommend you to change the last del command with something safer, like echo which just prints out the file.

Oh yeah, **DISCLAIMER**. Don’t just randomly copy past Powershell code and execute it on your machine if you don’t know what you are doing. Certainly if it’s deleting files like the example above. You might end up deleting more than you bargained for.  :)

Photo by James Vaughan, cc-licensed.

how to get code from tfs from the command line

cmd.exe

Ever wanted to pull an update from the TFS server for all workspaces you have without having to start up the Visual Studio? Well I did. Visual Studio is rather slow in starting up and then you have to navigate to the TFS explorer (clicky clicky) and manually update the workspaces (clicky clicky) and then wait till the whole thing is done and VS becomes responsive again (waity waity).

You have the tf.exe command which you can use from a command prompt, but that requires you to use the VS command line because the right paths are set there. You could set the paths so they are available in all your shells, but that’s not very handy either.

I just wanted a batch script that I could run from any shell, that would just update my workspaces for me. Nice and easy.
Like when I press CTRL-R in Windows (Run) and type getfoo.cmd<enter>, it just makes it all happen for me.

So here’s how I did that:

@echo off

cls

:: Importing VS 2012 command line variables so we can run TF.exe
if exist "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat" (
echo Importing VS 2012 environment variables...
setlocal
call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat"
)

echo.
echo *** Updating TFS workspaces ***
echo.

:: Repeat this for all workspaces you want to update.
d:
cd D:\WS\pathtosolutionfiles\

tf get . /version:T /recursive

echo.
echo *** Workspace updated. ***
echo.