My Software Notes

Useful things I discover

Archive for the ‘Windows 7’ Category

Environmental Variables Disappearing In Windows

leave a comment »

I started noticing it a couple of days ago: icons on my task bar, such as the File Explorer, stopped working and gave me that annoying “application cannot be found” message. Other programs just stopped working.

I hunted around and found that my PATH variable in a console window was only listing the additional path items from the “User” environment. The “System” (aka “Machine”) PATH environmental variable was not being appended to the front of the “User” PATH.

I tried to open “Computer > Properties > Advanced Properties” and it said it couldn’t find the Advanced Properties dialog and it gave the path to the app using “%windir%”.  So I opened up a console and typed “SET” and the majority of the System environmental variables were missing.

What was going on?

I hunted and hunted and finally found this: Windows 7’s PATH and environment variables are corrupted.

Can you believe that? When your path goes over 2048 characters long the entire environmental variables handling in Windows goes haywire.

I edited my PATH and took out a bunch of duplicate entries (what added those?), got it down to a much smaller size and suddenly my Win7 machine was working perfectly again.

It seems like a serious omission that Windows gives no warning at all that there is a problem and we poor buggers have to figure out what to do.

I hope this post helps someone out there with the same headache.


Written by gsdwriter

October 31, 2013 at 12:05 pm

“Unable to attach to process. A debugger is already attached.” (VS 2010, Classic ASP)

with 2 comments


A fellow developer was using Visual Studio 2010 SP1 to debug a classic ASP application.  He attempted to attach to the IIS process, w3wp.exe and received the error message: “Unable to attach to process. A debugger is already attached.”


He is running Windows 7, 32 bit. (But I reproduced the error on Win7 64 bit.)

He is using IIS 7.5.

Yesterday he installed IE 10 32 bit. (Yesterday I installed IE 10 64 bit.)

We looked in Process Explorer but no debugger was running that we could see.

We tried changing the “Attach to” type in the “Attach to Process” dialog, but it had no effect.

We tried all sorts of things but nothing made any difference.

I found this forum article:  Visual Studio 2010 debugger already attached classic ASP

I tried debugging the same ASP site by attaching to the IIS process, using VS 2012 and it worked perfectly.


Use VS 2012 or revert from IE 10 for Win7 to IE 9.


My fellow developer is installing VS 2012. (I don’t know why he didn’t do it already – heck, it’s worth it just for that cool Dark Theme.)

I hope that helps anyone hitting this issue.

Written by gsdwriter

March 1, 2013 at 1:36 pm

List RSA Key Container Names

with 6 comments

Recently I’ve been looking into encrypting sections of web.config on a couple of web sites that reside on a web farm.

It’s not very difficult (once you figure out how to get around the fact that some of the instructions don’t work) and I’ll write another post on it once I’ve finished implementing it. But there is one major weak point: What happens if you forget the name of the key you are using?  Where do you go to find the names of the RSA keys?

You’d think that listing the names of RSA key containers would be simple.  After all, they are real easy to create just type:

aspnet_regiis -pc "MyKeys" -exp

(aspnet_regiis can be found in C:\WINDOWS\Microsoft.Net\Framework\v2.0.50727  or higher)

It’s so simple to do and yet if you forget the name you used then finding it again is virtually impossible.

After many, many searches on Google, Bing and DuckDuckGo, I finally found something that will list them.  (Surprisingly it was highest on the DuckDuckGo search and that’s how I found it.)

It’s a simple open source app called KeyPal.  Download it, open up a command prompt and run it.  At start up it gives you a list of user keys, a list of commands and a blank prompt (with no “>” or anything to indicate it’s a prompt).  To list machine level key containers just type “LM”, press Enter and there they are!

There is probably something in the bowels of Windows that will also do this, but I couldn’t find it after searching and searching, so kudos to the guys at JavaScience who wrote KeyPal.

I hope this gets onto search engines to help other poor slobs like me find out how to list RSA Key Container names without spending hours hunting.

Written by gsdwriter

August 6, 2012 at 12:08 pm

Replacing Notepad.exe

leave a comment »

You want to use your favorite text editor rather than Notepad.  It seems like you could just rename the exe of your favorite to “notepad.exe” and drop it into the Windows directory.  But it won’t work.

First your favorite text editor may not be composed of just one exe file.  Second Windows regards Notepad as part of its installation and Windows Protection will overwrite your text editor at some point.

But there is a way to do it and here it is:

(I’m using Notepad++ as my example text editor. You can alter the various paths and file names to suite your own situation.)

1. Create a cmd file containing these two lines:

@echo off 
start "" "C:\Program Files (x86)\Notepad++\notepad++.exe" %2 %3 %4 %5 %6

Save it in the Notepad++ folder. Call it npplauncher.cmd

2. Open regedit and navigate to:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\

3. Add a key under “Image File Execution Options”. Name the key “notepad.exe”.

4. To the key add a string value with the name “Debugger” and the value “C:\Program Files (x86)\Notepad++\npplauncher.cmd”.

That should do it.  Now just double-click a txt file or type “notepad myfile.txt” at the command line and your text editor will open instead of Notepad.


Q: Why do we drop %1 in the cmd file? 

The command line you use when you attempt to run your text editor will look something like “notepad myfile.txt”.  This entire command line is passed to npplauncher.cmd and the first parameter will be “notepad”, which you don’t want to open in your text editor, so we drop it.

Q: Why do you have an empty string as the first parameter to the start command?

If the first parameter to start has quotes around it then start treats it as the title of the window that it will open.  If you omit the empty string then “C:\Program Files (x86)\Notepad++\notepad++.exe” will be treated as a title and not as a program to run.  Here is where I found this:

Q: Why do you put the editor’s name into the “Debugger” string value?

It launches the application you’ve named as the debugger for the application named in the key.  I.e., “C:\Program Files (x86)\Notepad++\notepad++.exe” is regarded as the debugger for “notepad.exe”.  For a much better explanation see this: Replacing Windows Applications – the Safe Way.

Q: Why do I need the npplauncher.cmd file?

You can get around it if your editor has a way for you to ignore the first parameter.  The only reason for the cmd file is to ignore that first parameter.  See the “Replacing Windows Applications – the Safe Way” article I linked to ealier for details.  I guess another reason for the cmd would be if there are other things you want to do to the command line before passing it on to the text editor, e.g., for Notepad++ you could add the -multiInst parameter.

Q: Why do you have %2 through %6 in your cmd file?

I just decided to pass up to 5 parameters.  If you want more then add more.  If you want to get really fancy then you can probably find some crazy DOS command that will allow you to pass the entire command line minus the first parameter.

Q: I use Notepad++ and I want to use the -multiInst parameter.  How do I do that?

Just put -multiInst before the %2 in the cmd file.

start "" "C:\Program Files (x86)\Notepad++\notepad++.exe" -multiInst %2 %3 %4 %5 %6


So that’s it.  Pretty easy really, once you know.

Other references:


Written by gsdwriter

July 11, 2012 at 3:11 pm

Virtual PC 2007 on Windows 7

leave a comment »

I really like Windows 7.  I installed it last weekend and it’s great. Much better than Vista with a lot of handy new UI improvements and MUCH better utilization of resources.

I hit one issue today: The wonderful, fabulous, everybody-must-have, I’m-wetting-myself-over-how-great-these-are new features called “Windows Virtual PC” and “Windows XP Mode”.  I’m sure they are just as great as the hype says they are but there is one major gotcha: “Is AMD-V or Intel VT a must-have to run Windows Virtual PC?”  Answer: YES.  So if you ain’t got hardware virtualization on your PC then forget both of these features.

My laptop does not have hardware virtualization, so I thought I’d see if  Virtual PC 2007, which I still have installed, runs on Win7 and I got warnings about network drivers and although it opened up my VMs, there was no network connectivity.  Great.  So in a moment of inspiration I uninstalled it and reinstalled it and, so far, it is working fine.

So, the good news is that Virtual PC 2007 still works – if you uninstall and reinstall.  Maybe there is a better way around the issue, but that’s what I had to do to get it to work.

My final complaint is that I have not yet found anywhere on that says you can run Virtual PC 2007 on Windows 7.  If any MSFT people are reading this then (hint, hint) the Windows Virtual PC FAQs would be a nice place to answer the question: “I don’t have hardware virtualization on my PC, can I still use Virtual PC 2007 on Windows 7?”

Written by gsdwriter

November 8, 2009 at 3:56 pm

Posted in Windows 7

Tagged with , , ,