Deleting files that Windows can’t delete

I recently downloaded some files from Salesforce Chatter which ended in “….”

If Windows won’t let you delete them (it says they don’t exist), SysInternals sdelete will:

C:\tools\SysinternalsSuite\sdelete.exe /s “\\?\C:\Users\TRobinson\Desktop\Over the next few weeks….”

Beware of non-breaking spaces in your HOSTS file

I recently had some problems with HOSTS file entries that were being ignored. When viewed in most text editors it looked correct, but what looked like harmless whitespace was actually a non-breaking space (Decimal 160 or Hex A0). Although you can use tabs or spaces to separate the IP address from the hostname in HOSTS file, it treats non-breaking spaces as part of the hostname and therefore doesn’t work as expected.

Dashlane Easter Egg – Konami Code reveals Conway’s Game of Life

I’ve been a Dashlane user for a while now, having found out about it through a friend and respected colleague who started working for them in the Paris office.

What you may not know is that Dashlane have invited a number of people to be on their “Board of Users” and to give feedback on new product developments. A few days ago one of the QA Engineers set us all a challenge – to find a hidden “cheat code” in the PC version of the application.

Well, I found it! (and I think I was the first)

It turns out that if you open the application, then go to the Help > About screen you’ll initially see this:

about-before

Now comes the fun part, you need to type the Konami Code:

↑ ↑ ↓ ↓ ← → ← → A

As soon as you finish that, you’ll see this screen and the Easter Egg will have been activated:

about-after

Initially I though, hmm, interesting, is it some kind of icon editor? You can start drawing on the grid, like this:

about-start

But as soon as you click the Dashlane logo then the grid turns into Conway’s Game of Life:

about-running

The guys at Dashlane have been kind enough to offer to send me some goodies but the main prize is this signed Dashlane drawing from the team at Dashlane in Paris:

Dashlane Konami Code Scan

Thanks all!

Powershell: -contains vs. -match and -like

I recently discovered a problem where the Where-Object –contains operator wasn’t doing what I thought it was, i.e. the equivalent of String.Contains() in C#. For example:

(Get-Item .\MyDirectory) | where { $_.Attributes -contains “Directory” }

Is not the same as:

(Get-Item .\MyDirectory) | where { $_.Attributes -match “Directory” }

The former fails if the directory has more than one attribute. The reason for this is:

-contains is designed to work on arrays, not strings (referred to as a containment operator)
-match looks for a match inside a string and supports regexes
-like looks for a match inside a string and supports wildcards

So if the directory only has one attribute then –contains sees it as an array with a single entry “Directory” and returns true.
But if the directory has multiple attributes then –contains still sees it as an array with a single entry but the value of that entry is “Directory,NotIndexed” so returns false.

http://www.techotopia.com/index.php/Windows_PowerShell_1.0_Comparison_and_Containment_Operators

Remote debugging

If you have problems remote debugging then make sure you check all the boxes in the Control Panel\All Control Panel Items\Windows Firewall\Allowed Programs screen.

You may or may not have two entries, I don’t know what causes this.

Untitled

IIS Configuration

We recently needed to make sure that anonymous authentication was enabled (at the IIS level) for an application, regardless of the defaults or configuration of the server the application was being installed on.

To do this you can add the following (as a sibling of <system.web>) in the Web.config to make the required IIS authentication settings explicit:

 <system.webServer>
      <security>
         <authentication>
            <anonymousAuthentication enabled="true" />
         </authentication>
      </security>
   </system.webServer>

This will override any settings made in the IIS Manager and the applicationHost.config file.

Whilst on this subject, it’s worth mentioning that you can also configure IIS on the command line using something like this:

appcmd.exe set config "Contoso"
    -section:system.webServer/security/authentication/windowsAuthentication
    /enabled:"True"
    /commit:apphost

There is lots more inforomation about the various settings here:
http://www.iis.net/ConfigReference/system.webServer/security

However, we hit a slight snag with this.

Although we can put the setting in the web.config, the default IIS permissions prevent this particular set of settings from being modifed in the web.config unless you explicitly enable these settings to be delegated to the web.config.

See:
http://learn.iis.net/page.aspx/159/configuring-remote-administration-and-feature-delegation-in-iis-7/

Given that anonymous authentication is enabled by default (unless we’ve changed it as part of the machine image) then for this particular case we felt that it would be simplest just to assume that IIS is set up correctly. We would soon notice if this wasn’t the case.

The better long-term solution would be to make sure that we set up the IIS delegation permissions as part of machine/image setup – to allow us to configure this setting and others in the web.config. This can be done via the command line so could be part of a server setup script.

Adding the Visual Studio 2010 Command Prompt variables to your PowerShell profile

If you add the following to your PowerShell profile then you’ll have access to all the commands only normally available by opening the Visual Studio 2010 Command Prompt:

# Set environment variables for Visual Studio Command Prompt
# Based on: http://stackoverflow.com/questions/2124753/how-i-can-use-powershell-with-the-visual-studio-2010-command-prompt
pushd 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC'
cmd /c "vcvarsall.bat&set" |
foreach {
  if ($_ -match "=") {
    $v = $_.split("="); set-item -force -path "ENV:\$($v[0])"  -value "$($v[1])"
  }
}
popd
write-host "`nVisual Studio 2010 Command Prompt variables set." -ForegroundColor Yellow

Your PowerShell profile will be somewhere like this:

C:\Users\trobinson\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

printmanagement.msc

I’d not come across this until today, when I was having problems installing some printer drivers. It lets you list and remove printer drivers very easily.

Just run this: printmanagement.msc