Tag Archives: Windows XP

Disappearing folder – bug in Windows 7

In process of testing one of our automation software I hit interesting Windows 7 bug. First I found it in our software, and right away tested this scenario on Windows 7, and bug was there.

The bug. Create folder on the Desktop.

Right click on Desktop
New folder

New folder appears and cursor blinks allowing to change the name for the folder.

Cursor at the end

Place cursor at the end of folder name, and enter dot (.) character.

Dot at the end

After pressing Enter key the folder disappears.

Folder disappears

But do not worry, it will come back after reboot, or after refresh (F5 key).

After refresh

Appears that this bug/behavior… that only Windows 7 is affected. Other Windows versions I tested does not have this bug, even Windows XP and upcoming Windows 8 behaves correctly (see screenshots at the end of the post).

A side note. By “correctly” in this case I mean, that folder does not disappear, however perhaps, there is another bug. The dot “.” character disappears in all Windows versions. This of course depends on interpretation, for example, I also tested this on Ubuntu 10, and Ubuntu (and probably most nixes) allows dot (.) at the end of filename.

Why this happens? Every filename consists of two parts: filename and extension. These two parts are separated by dot (.) character. Windows Shell hides this dot from you, and when you enter “filename.”, it thinks, that this must be a filename without extension, so it stores only filename. In theory you should be able to trick shell by adding more dots, like “filename…”, but Windows 7 Shell reduces them to no dot. Of course you can create file or folder with one or more dots at the end, but for this you will need a normal file manager, like Far Manager (which is open source). Also, keep in mind, that you will not be able to delete this file or folder from desktop using Windows Shell, you will need to switch to file manager again.

Note 1. Windows Server 2008 R2 is based on the same codebase, so it has the same bug.
Note 2. Operating Systems used in the test:

  • Windows 7 Professional 64-bit
  • Windows Vista Enterprise
  • Windows Server 2008 Enterprise
  • Windows Server 2008 R2 Datacenter
  • Windows Server 2003 Enterprise
  • Windows 8 Consumer preview
  • Windows XP
  • Ubuntu 10

CreateProcessAsUser fails on Windows XP with System error 233

Today I fixed one bug that was very hard to reproduce. Many hours were spent to figure out what combination caused it:

  • It happens only on Windows XP (not on Vista, Server 2003, 2008, Win 7);
  • It does not happens on all Windows XP, because it is Race condition;
  • I was unable to reproduce it with physical glass/monitor attached to the computer; It only happened using Remote Desktop;
  • It does not happen when debugger is attached and breakpoint is being hit;

Latter I found people that have similar issue:

The code is the following:
WTSQueryUserToken(..., &hToken);
SetTokenInformation(hToken, ...);
SomeVistaAndWin7ElevatedTokenStuff(hToken);
CreateProcessAsUser(hToken, ...);

And CreateProcessAsUser fails with GetLastError() = 233. Looking in System Error Codes (0-499) – ERROR_PIPE_NOT_CONNECTED 233 (0xE9) – No process is on the other end of the pipe.

The confusing part is about Pipe, because you didn’t expect to get pipe error here – you have not created any pipe.

In the first post I have linked, Thomas Graefenhain writes:

I’ve debugged a little bit with the kernel debugger, and have found the
problem: CreateProcessAsUser uses internally, when creating a process in an
other session, the function CreateRemoteProcessW from ADVAPI32.DLL. This
function opens a pipe with the name
\\.\Pipe\TerminalServer\SystemExecSrvr\%d where %d is the SessionID and
sending the request over to csrss.exe. …

In another post someone mentioned that Sleep(2000) fixed the problem. This explains why under debugger everything works without an error.

The good news is that it happens only under Windows XP and under Remote Desktop, so small group of users are affected. The bad new is that there are no elegant workarounds. Windows XP is in the Extended Support Phase, so I am not counting on fix from Microsoft.

Currently I use the following workaround (simplified version, see below). If you have something better or more elegant, please let me know in the comments below.
{
     Sleep(100);
     CreateProcessAsUser(hToken, ...);
} while (wasError && GetLastError() == 233 && IsWindowsXP());

Windows XP menu ‘Add mirror’ greyed out

Today I was trying to make a software RAID 1 in Windows XP Professional. I thought I have done that a couple times, but today somehow menu Add mirror stayed inactive.

I did a google search and to my surprise two KB articles from Microsoft support came out.

They both have the following paragraph:

You cannot create mirrored volumes on computers that are running Windows XP Home Edition, Windows XP Professional or Windows XP 64-Bit Edition. However, you can use a computer that is running Windows XP Professional to create mirrored volumes on remote computers that are running Windows 2000 Server, Windows 2000 Advanced Server, or Windows 2000 Datacenter Server. You must have administrative privileges on the remote computer to do this.

So how it is possible, that I have created such volumes in the past? Perhaps in Windows Server or in my dreams.

Also, there is a known hack that involves changing system files with a hex editor, but this is one of my production machines, so I will not take a risk, and I would not recommend this hack to anyone. Use the following link on your own risk (I warned you): How to enable software RAID 1 in Windows XP (hack).