Category Archives: microsoft

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

 

fixing MSB3644 build errors and the point of .NET targeting packs

Build errors on build servers suck. If it builds locally, why the hell doesn’t it build on the build server? Well there’s plenty of reasons for that, but as a .NET developer is usually means that something you have on your machine that came with your Visual Studio install isn’t installed on the build server.
But you probably don’t want to install the full-blown VS on the build server, so the question now is: what bit do I need to install?

Recently I ran into the following build error on 1 specific build server (yep, not on another one, fun, fun, fun).

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin\Microsoft.Common.CurrentVersion.targets(1111, 5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.5.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

It clearly has something to do with a project which targets .NET framework v4.5.2.
The answer in fact is right there. You need to install a “targeting pack”.
But WTF is that thing and why do I need it?

Apparently having the .NET framework itself installed on your machine isn’t enough to be able to build a project if that project targets a specific version of the .NET framework. It makes sense as the .NET framework installation is actually the runtime, used to run .NET applications, not build them.
If you want to build apps against a specific version of the .NET framework, you need that targeting pack as well on your build machine. This is either your development box, which has VS on it, and thus the required targeting packs which come with the VS installation. Or this can be your build server, where you have to install the targeting packs as well.

You can check what targeting packs you already have on a machine by checking the sub-folders in “C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework
For each supported framework version, there’s a v<version number> folder there. In my case there was no v4.5.2 folder on that one machine.

So where do you find those targeting packs for the various .NET framework versions? Microsoft luckily compiled a nice list where you can find all the download links and instructions.
For the versions listed as “included in VS 2017”, you can see them all listed in the VS 2017 installer if you go to the “Individual components” tab.

Look at all those .NET targeting packs.

So a shortcut to install all the packs at once, is to grab the VS2017 installer and use that one. But you might want to disable all the IDE specific stuff you won’t need on the build server though.

cure cancer with leftover azure credits

An azure window grid, reflecting clouds. Perfect fit isn't it?Maybe you have some Azure credits lying from a Visual Studio subscription you have from work, waiting to be spent on cool and nifty experiments, but don’t end up actually using them.
How about spending some of those dollars on cancer research? Or help find a cure against Zika? Fighting AIDS maybe?

Enter the World Community Grid, a vast grid computing network running on the Open Source BOINC client software, started as a philanthropic initiative by IBM.
Sounds good right?

All you need to do is create a WCG account, spin up a Linux machine on Azure, install the BOINC headless client on it and link it to your account. In about half an hour you’ll be computing cancer markers, folding genes or fighting some horrible disease. Well, the software will be doing that really, which is even better.

Here we go, step by step.

1. Setup your Azure Linux machine, I chose an Ubuntu 16 LTS machine. I pick the classic VM because its way easier to setup.
Depending on the type of machine you’ll have more compute power and thus turning out more results. Try a few out and see how you can maximize your Azure credits.

2. Once provisioned, log in using PUTTY or your favorite SSH client. Now it’s time to update the Linux packages and then install the BOINC client:

sudo apt-get update
sudo apt-get install boinc-client

3. Setup auto startup of the BOINC client, so if your machine reboots, you don’t have to go in and start it up yourself (automate all the things remember):

sudo /etc/init.d/boinc-client restart

4. Get your BOINC authentication key so you can hook up the client to your account:

boinccmd --lookup_account https://www.worldcommunitygrid.org

5. Now use the key to attach your selected projects from WCG:

boinccmd --project_attach https://www.worldcommunitygrid.org

Of course you want to check what’s going on, so you can check the BOINC client’s state like this:

boinccmd --get_state

This should give you a list of the tasks and their state. It might take a while before they start kicking in, but you’ll see results coming in after a day or so on the WGC website under your contribution history.

That’s about it. Your client is all set up. All you need to do is keep those VM’s running in the cloud, which normally takes non effort at all. Neat.

There are more boinccmd command line switches in the documentation if you’d need to troubleshoot or find out more.

What’s next? Well, you can set up more than 1 machine if you like, or a heavier one and see what gives you more bang for your buck.¬† You can also join my World Computing Grid team called “Team Azure” and see how many cloud bucks we can burn. It’ll be effortless fun, I promise! ;)

Credit goes to Joel Christian’s headless Ubuntu installation guide. His guide made my quest to setup BOINC on an Azure Ubuntu box a lot easier.

Photo by Dan, cc-licensed.

getting a web page with basic authentication using powershell

pont d'amour Getting a web page using PowerShell is pretty easy using Invoke-WebRequest. Getting a web page which is protected using basic authentication isn’t that much harder, but it took me a while to find out how to do that exactly as my initial searches didn’t turn up the right answers.

The trick is that you have to pass in a credential object when you make the call:

$result = Invoke-WebRequest http://foo.com -Credential $credential

That $credential object is something you have to create. If you don’t pass in an object, you’ll get a prompt btw, which might also be handy.
Creating the object is done like this:

$user = "john.doe"
$password = ConvertTo-SecureString "a_password" -AsPlaintext -Force
$credential = New-Object PSCredential($user, $password)

The PSCredential object is created and the username and a secure password string is passed into the constructor.

Putting the username and password in your script like this is a bad idea in a lot of cases, so you should really consider if this what you want to do. You can also use the Get-Credential cmdlet to ask the user for the username and password instead.
That way you keep this sensitive data out of your script and make it more resilient to change as well.
This is all it takes to ask for the credentials and set them into a variable you use later on:

$credential = Get-Credential

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.

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.

mstsc.exe crashes on Windows 8 (and how to fix it)

Physical View of the Network

When using MSTSC (Microsoft Terminal Server Client aka RDP or Remote Desktop on Windows) to dial into a local HyperV virtual machine on my laptop it often happened that MSTSC crashed on me. When reconnecting afterwards, the VM was running just fine. So it seemed to be an issue on my local machine and not the VM. I assumed it had something to do with HyperV and RDP and didn’t look into it any further (I didn’t need it that much after all).

The exception code I got in my Event Viewer for the crash was 0xc0000005 on ntdll.dll.

But then I kept having this problem so often when connecting to a physical machine in the network it annoyed me enough to Google for a possible solution.
One post pointed me in the right direction (which I can’t find anymore, sorry about that), being that it had something to do with sharing of local resources. In my case I recently activated the option to transfer sound between the remote and my local machine so I could use Skype & Linq.

Turns out that was indeed the culprit. Whenever my remote machine made a sound, my RDP client crashed. Bummer!
Turning off sound transferring to my host machine made the crashes go away. Sweet!

So if you also run into this, try turning off some of those local resources.

It still sucks if you need sound of course, but in my case, I can live with the silence.

Photo by Robin Gist, cc-licensed.