Today I had to diagnose a problem with a Windows Scheduled Task that was sporadically failing with a non-zero return code. The exe in question was a .NET console application that was throwing an exception before Main() got called; it was outside our try-catch block.

failing-tasks

Anyway, if you ran the .exe from a command line yourself, you would see the error written to stderr. If you ran the Scheduled Task, the error was not logged anywhere.

To capture the output of the scheduled task, I redirected it to a text file with the following command:

before: NightlyBatchJob.exe

after: cmd /C NightlyBatchJob.exe >> NightlyBatchJob.output.txt 2>&1

The > symbol redirects the output to a file; >> makes it append instead of creating a new blank file each time it runs. 2>&1 makes it include the output from stderr with stdout — without it you won’t see any errors in your logs.

task

The whole command is run in a new cmd.exe instance, because just running an .exe directly from a scheduled task doesn’t seem to produce any console output at all.

January 26th, 2009 | 3 Comments

At work over the past few months I have occasionally encountered a rather strange problem on newly-installed PCs. The problem is quite simple:

  • If you type a single quote (‘) or double quote (“), nothing happens.
  • If you type another, two suddenly appear.

Furthermore, if you hit a quote key at one position then move the cursor and hit it again, both quotes will appear at the second location.

This feature is common to both Windows Vista and XP, and seems to appear when you have extra English-language keyboards added like UK and NZ. I’m not really sure what it’s purpose is, but I found it very annoying.

Here’s how I fixed it:

  1. Open the Regional and Language Options control panel.
  2. Click on the Keyboards and Languages tab. Click on the Change Keyboards button.
  3. Remove all the installed keyboards until none are left except English US. It should look something like this:
    Text Services and Input Languages
  4. Restart your computer.
February 2nd, 2008 | 4 Comments

I have just got a new computer at work, and over the past week I have been installing all the software that I like to use. One tool I rely on is IISAdmin, a program that sits in the system tray and allows you to run multiple IIS websites under non-server editions of Windows. Unfortunately, when I tried to install it under Window Vista, it failed with the message “Error 1904. Module C:Program Filesiisadminztray.ocx failed to register. HRESULT -2147024770. Contact your support personnel.”

IISAdmin setup error 1904

Attempting to manually register the module with RegSvr32 didn’t work either:

The module "ztray.ocx" failed to load.

I couldn’t find anything searching for either of the error messages, so I did some digging on the module itself. It turns out that ztray.ocx is an old (1997) ActiveX control that allows programs to add an icon to the system tray.

I eventually found Dependency Walker, a tool that scans Windows modules for dependencies. I opened up ztray.ocx to see if it was missing anything.

Viewing ztray.ocx with Dependency Walker

As you can see, ztray.ocx makes calls to a module called msvbvm50.dll, part of the Visual Basic 5.0 run-time. This package is present in Windows XP, but appears to have been dropped from Vista. Luckily it is still available as a free download from Microsoft. Installing it solved the dependency problem, and I was able to install IISAdmin successfully.

December 16th, 2007 | 4 Comments