Urih.com statistics – you never know what will be most used feature

22 weeks (or 5 months and 5 days) after urih.com launch, here we have an interesting stats. Clearly, the most used feature on the urih.com is SilverBench – online CPU benchmark tool.

The opposite – the feature that no one have used is: Feedback form, that is located on all pages.

To be exact, the Feedback feature is used exactly 0 (zero, null, none) times. However SilverBench is used many, many times each day. If you look at the SilverBench results page, you can see, that from 5 – 10 people submit their benchmark scores every day.

So no one can predict, that after 22 weeks, the one of the most prominent features will not be used even single time.

P.S. Forgot to mention, that 36 days ago we launched HTTP Response header tool. An online tool, that can be used to view HTTP header stats and information for any site in the Internet.

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());

Microsoft’s PowerShell hangs when output is captured using Windows API

I was debugging a program that uses Windows API (Creating a Child Process with Redirected Input and Output) to capture stdout of Microsoft’s Windows PowerShell.

Script passed to PowerShell (-File switch) didn’t execute and PowerShell just hanged until killed by Task Manager.

It turns out that you need to use undocumented parameter “-InputFormat none”:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -InputFormat none -File file.ps1

This is discussed in MS Connect site: PowerShell.exe can hang if STDIN is redirected.

Similar issue at StackOverflow: Silently executing a PowerShell script from WiX Hangs PowerShell.