Tag Archives: Windows

Windows Update error code list

Just as a reference since I’m also always looking for these myself(pulling my already missing hair out). A list of Windows Update error codes.


One small note. The best one is 0x80240FFF… (WU_E_UNEXPECTED An operation failed due to reasons not covered by another error code). They should just have changed the wording to be a slight bit more honest and say: ‘An error occurred and we haven’t got a clue what it is (as usual)’ 😉

Deleting a folder with path that is too long

Just a quick tip I came across today after having a problem where I found a directory where some tool went nuts and kept on creating subdirectories recursively. Trying to delete this directory will give you an error – something like ‘Path is too long…’

Lets say the path is something like d:\directory1\directory1\directory1\directory1…..\directory1

Windows Explorer and even Command prompt won’t allow you to delete d:\dir1 (No not even right-click delete will work).

A simple solution is to recursively go and rename all the directories to something much shorter so the overall length is less that the maximum (260 characters).

Like this: rename d:\directory1 0  , rename d:\0\directory1 0 etc.

The end result should be like this: d:\0\0\0\0… \0

Now you can simply delete it in Windows Explorer without any ‘Path Too long’ errors.

Creating a Multi-instance self registering service

This is one of those things I’ve been wanting to do for a long time for my Event Scavenger pet project. Basically the requirement is this:

“Being able to have one executable (.exe) file that can be used multiple times for different service instances.”

It turns out it is not too hard to achieve this using C# and .Net 4.0 (might even work with older frameworks but haven’t tried it). It is an extension of my already improved self registering Windows Service extensions which make it possible to simply run the Service exe with a ‘-install’ command line parameter. With the latest additions a ‘named’ instance can also be specified. This means, in the Service Manager of Windows you can see the Service executable plus a command line parameter that makes it unique. It allows you to stop/start/manage it separately as an entity. This is exactly the same as how Microsoft BizTalk Server implements ‘Host Instances’.

Now lets get dirty with some code samples. The first code snippet shows (an example) part of main program.cs that handles the command like parameters.

string collectorName = "Default";		

if (args.Length > 0)
  if (args[0].ToUpper() == "-INSTALL")
              string serviceParameters = "";
    if (args.Length > 1)
      collectorName = args[1];
                  serviceName = "Event Reaper - " + collectorName;
      displayName = "Event Reaper - " + collectorName;
                  serviceParameters = "\"-Collector:" + collectorName + "\"";
    if (args.Length > 2)
      displayName = args[2];
    if (args.Length > 3)
      description = args[3];

  else if (args[0].ToUpper() == "-UNINSTALL")
    if (args.Length > 1)
      collectorName = args[1];
                  serviceName = "Event Reaper - " + collectorName;
  collectorName = HenIT.CommandLineUtils.GetCommand(args, "", "-Collector:");
if (collectorName.Length == 0)
  collectorName = Properties.Settings.Default.CollectorName;

ServiceBase[] servicesToRun;
servicesToRun = new ServiceBase[] 
  new EventReaperService() { CollectorName = collectorName }

All this section does is to check for the “-INSTALL” or “-UNINSTALL” parameters and then call the helper class that does the registration/unregistration. The Display name of the service instance is always prefixed with “Event Reaper – ” to grouped all instances visually together in Service manager.


The ServiceRegister class only has two methods. InstallService is the first one and handles all the bits to gather login details, set properties and then register the service.

public static bool InstallService(string serviceExePath,
        string serviceName,
        string displayName,
        string description,
        string serviceParameters)
    bool success = false;
        string workingPath = System.IO.Path.GetDirectoryName(serviceExePath);
        string logPath = System.IO.Path.Combine(workingPath, "Install.log");
        ServiceStartMode startmode = ServiceStartMode.Automatic;
        ServiceAccount account = ServiceAccount.LocalService;
        string username = "";
        string password = "";
        bool delayedStart = true;

        InstallerForm installerForm = new InstallerForm();
        installerForm.StartType = ServiceStartMode.Automatic;
        installerForm.AccountType = ServiceAccount.User;
        installerForm.TopMost = true;
        if (installerForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            startmode = installerForm.StartType;
            account = installerForm.AccountType;
            delayedStart = installerForm.DelayedStart;
            if (installerForm.AccountType == ServiceAccount.User)
                username = installerForm.UserName;
                password = installerForm.Password;

            Hashtable savedState = new Hashtable();
            ProjectInstallerForHelper myProjectInstaller = new ProjectInstallerForHelper(delayedStart);
            InstallContext myInstallContext = new InstallContext(logPath, new string[] { });
            myProjectInstaller.Context = myInstallContext;
            myProjectInstaller.ServiceName = serviceName;
            myProjectInstaller.DisplayName = displayName;
            myProjectInstaller.Description = description;
            myProjectInstaller.StartType = startmode;
            myProjectInstaller.Account = account;
            if (account == ServiceAccount.User)
                myProjectInstaller.ServiceUsername = username;
                myProjectInstaller.ServicePassword = password;
            myProjectInstaller.Context.Parameters["AssemblyPath"] = serviceExePath + " " + serviceParameters;

            success = true;
    catch (Exception ex)
        System.Windows.Forms.MessageBox.Show(ex.Message, "Install service", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
    return success;

The class InstallerForm is simply a plain Windows Form to capture service properties like the username/password etc. I’m not showing its code here now. AssemblyPath is the actual property that Service manager use to launch the executable plus its parameters.

ProjectInstallerForHelper is an utility class that simply inherits from System.Configuration.Install.Installer. It looks like this:

internal class ProjectInstallerForHelper : System.Configuration.Install.Installer
    private ServiceProcessInstaller processInstaller;
    private System.ServiceProcess.ServiceInstaller serviceInstaller;

    public ProjectInstallerForHelper(bool delayedAutoStart = true)
        processInstaller = new ServiceProcessInstaller();
        serviceInstaller = new System.ServiceProcess.ServiceInstaller();
        serviceInstaller.DelayedAutoStart = delayedAutoStart;

        Installers.AddRange(new Installer[] {

    #region Added properties
    public string ServiceName
        get { return serviceInstaller.ServiceName; }
        set { serviceInstaller.ServiceName = value; }
    public string DisplayName
        get { return serviceInstaller.DisplayName; }
        set { serviceInstaller.DisplayName = value; }
    public string Description
        get { return serviceInstaller.Description; }
        set { serviceInstaller.Description = value; }
    public ServiceStartMode StartType
        get { return serviceInstaller.StartType; }
        set { serviceInstaller.StartType = value; }
    public ServiceAccount Account
        get { return processInstaller.Account; }
        set { processInstaller.Account = value; }
    public string ServiceUsername
        get { return processInstaller.Username; }
        set { processInstaller.Username = value; }
    public string ServicePassword
        get { return processInstaller.Password; }
        set { processInstaller.Password = value; }


This is essentially just the reverse of InstallService.

public static bool UnInstallService(string serviceExePath, string serviceName)
    bool success = false;
        ServiceController sc = new ServiceController(serviceName);
        if (sc == null)
            System.Windows.Forms.MessageBox.Show("Service not installed or accessible!", "Stopping service", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
            return true;
        if (sc.Status == ServiceControllerStatus.Running || sc.Status == ServiceControllerStatus.Paused)
    catch (Exception ex)
        if (!ex.Message.Contains("was not found on computer"))
            System.Windows.Forms.MessageBox.Show(ex.Message, "Stopping service", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            return true;
        string workingPath = System.IO.Path.GetDirectoryName(serviceExePath);
        string logPath = System.IO.Path.Combine(workingPath, "Install.log");

        ServiceInstaller myServiceInstaller = new ServiceInstaller();
        InstallContext Context = new InstallContext(logPath, null);
        myServiceInstaller.Context = Context;
        myServiceInstaller.ServiceName = serviceName;
        success = true;
    catch (Exception ex)
        System.Windows.Forms.MessageBox.Show(ex.Message, "Uninstall service", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
    return success;


And this is basically the whole thing that allows you to create a Windows Service in C# that can handle multiple instances. There are a few things to keep in mind like the fact that all instances share the same config file unless you make a physical copy of the exe and config file to another directory and register it from there. Using this you can multiple services using different config all running side by side not affecting each other (hopefully hehe)

Windows 8 – Down with Metro

No, I haven’t managed to get the latest build or RTM of it yet and neither am I going to rush out to get it. I played with the Developer preview and then again with the Consumer preview plus I’ve been following online all the ‘progress’ (or lack thereof) and thoughts of other people and reviewers.

In recent news two ‘Gaming’ companies gave Windows 8 a thumb down for their own reasons. They probably also have alternative motives which I don’t even know about right now – and don’t care about. My ‘beef’ with it is more on the productivity and corporate fronts.

Let me try to explain a bit more.

The vast majority of ‘users’ I know use the desktop in Windows like a… {drumroll} real desktop with Icons cluttered all over the show. Some may say that is untidy and unproductive but most people (me included I admit) ‘know’ exactly where I left stuff in that mess (yes and my wife also hates that… hehe ). It all forms part of my thought or work processes as I may not be done with something yet and want to go on or repeat that action or process at some time again. Sounds familiar? That is why I create custom shortcuts or leave some files on my desktop. Lots, if not the majority of users do that.

Now, Retro (cough I mean… Metro) was probably (in part) made to help clean up that messy practice – but here is the problem – just like when my wife (or maid or whoever) go an clean or pack away stuff that I left there where I know about it, Microsoft went and try to ‘fix’ something that ain’t broken. I absolutely hate this! If they have to ‘fix’ Metro to do this it will become just another ‘desktop’, duhhh.

Further, Metro looks more like a toddler interface meant for babies or (cough) idiots. Yeh, I know, it is intended for the more ‘mobile’ space like tablets but I’m using a ‘desktop’ computer so why must I also be forced feed this ugly interface? I admit, it has its advantages but I can happily live without most of them for my purposes.

The ideal would simply have been that we still had the option to make the ‘classical’ desktop the default upon starting Windows. It can be system setting that you can choose either during set-up or through control panel or whatever system configuration tool they use. I have a suspicion that somewhere down the line they (MS) will be forced to implement this – mark my words!

Until then, Windows 8 will not see any of my computers where I have a say about it.

Update: Well, apparently the name ‘Metro’ itself has become almost poison to Microsoft themselves -due to trademark issues with a German retailer (Metro AG).

Windows Command Centre

A few years ago I created a quick utility to simply bring together all the various configuration tools that are included inside Windows itself. The problem is that there are actually all these built-in tools and utilities but finding them sometimes require you to search or discover them by accident. The tool I created simply provides an easy way to get to a lot of them. Even in Windows 7 not everything is located in one place – especially the more ‘advanced’, older or legacy tools – e.g. ODBC settings. Additionally I added something simple to simply ‘list’ the installed .Net versions as well.

A quick summary of what it contains:


Control panel
Manage computer
System config
Registry editor
Performance monitor
Scheduled tasks

Regional settings
Date and time


List versions
Disable Explorer GAC view


Device manager
Install hardware
Remove hardware
Power options
Disk management
Removable storage



Add & remove programs
Default programs
Windows components


Component services


Security centre
Firewall settings
User accounts
Local security settings


Network connections
Create share
Shared folders
Map network drive
Disconnect network drive
Internet options


Taskbar properties
Folder options
Display themes

I’ve now simple recompiled the utility and created a very simple installer for it (one for x86 and one for x64)

x86 – https://dl.dropbox.com/u/20983/WindowsCommandCentreSetup.msi

x64 – https://dl.dropbox.com/u/20983/WindowsCommandCentreSetupx64.msi

I’ve tested it on Windows 7 and it use to work on Vista/XP as well. Unfortunately I cannot guarantee that it will work properly on Windows 8 if at all. All it requires is the base .Net 2.0 framework to work.

Microsoft announce tablet

I have to admit, the general feeling towards Windows 8 is still not a positive one – definitely if you look at it from a desktop/productivity perspective. BUT, seeing the pictures of the newly announced Microsoft tablets there may be some hope for Microsoft/Windows – as long as you are in the ‘tablet’ or consumer market. They are to be branded ‘Surface’ or Microsoft boutique multi-touch tablets. Looks awsum! (but then these are marketing pictures…)

Microsoft tablet

Microsoft tablet (shamelessly copied from techreport site 😉 )

One positive feature of both (yes that’s right two) models is the battery life. The ARM (NVidia) based one has something like a 31 watt-hour battery while the Intel one has 42 watt-hour. If that is true these little machines would really be nice for people that are always on the move. The Intel model features a full HD display while the ARM model has an expansion slot (Micro HD). Both models include an detachable ‘soft’ keyboard. Storage is not in the PC arena but still a useful 32 or 64GB on the ARM model and 64/128GB on the Intel one.

Keyboard choices

Keyboard choices

On a slightly negative side they only have USB 2.0 ports (not 100% sure about the Intel one) plus only the ARM model includes a copy of Office. The tablets will be sold in Microsoft ‘stores’ thus meaning it won’t be available in our beloved S of A. Our only option would be to try to buy it online or smuggle one in with a friend that was visiting the US of A.

Well, good luck Microsoft, perhaps there is some hope for ya.

Update: apparently the Intel based version does have USB 3.0. Nice.

The future of the PC

First of, I’m coming from a background of mostly PC background (hardware, software, development, support and admin). I’ve been in ‘this’ business for more than 15 years (more actually) and have seen and lived through multiple waves of changes in the IT world – heck I still remember the days we were worried everything is going to stop working moving from DOS 6.22 to that ‘awful’ Windows 95 with the default graphical interface… hehe Anyway, I think we are the doorstep of such another major jump… well actually it is already busy, it’s just a matter of getting use to the new direction of the ‘flow’!

Second of, I don’t think the classic PC is going to disappear soon. No matter what the fruit company is telling everyone. But things are changing for the PC world and we can all (each one of us) choose whether we wanna go along for the ride or hang on to the side until the wave takes us in. Lately the trend is everything is going ‘mobile’ – or ‘without wires’ at least. It is ironic that Microsoft is one of those that actually had a finger in the pie starting all of this and each time something interesting started showing up they stayed behind. Now – no matter what they claim, they are playing catch-up. But it may not be a bad thing – then again it  could be…

Windows 8 and Microsoft

Personally I’m not a fan of Metro – but only if I’m viewing it from the traditional ‘PC side’. As an OS for touch devices like tablets it is really good! The issue is just that it doesn’t play nice with older stuff – like older hardware, software, users…. Hardware will eventually be replaced with newer stuff, software as well even though it might take a bit longer (some application vendors might take longer to adjust if they still exist…) and then users… that is where the ‘something brown’ hits the fan…. People get upset with change. Everyone does, its part of life. The older you are the more full of ‘brown stuff’ you become 🙂 However, even  users will adapt… eventually… hopefully. The question is how much will have changed in the interim until Microsoft can reclaim their old market share in terms of users, applications etc. Are they gona survive this transition? They might be big but even they can only survive ‘so long’ on ‘old cash’. Time will tell… They might end up with two sets of ‘user bases’, the old PC world and the new hip mobile world. They are big enough (now) to support it but like explained just above, things will change. All I can say is good luck and hold on tight!

Us developers

If you are in the world of application and system development then you should already know things have been changing (unless you are living on a tropical island isolated from the rest of the world – hey I’d like to be with ya!). The changes will require some rewriting of stuff, scrapping of others and creating some new ones as well. It could be interesting. Some old applications could be ported to the newer ‘world’. Others can’t be because they fundamentally work differently and require things that the mobile world can’t or not yet support. Take something like software development itself. It is kind of hard to do writing code on a tablet for several reasons – like screen size, multi tasking (running and debugging at the same time). Compiling code also takes up some real heavy resources – when dealing with ‘real’ systems being coded/developed. Mobiles just don’t have what it takes… yet.

Then, the current generation of touch devices mostly focus on touch (ok fruit company has a voice thing as well but it is really just a toy now). Perhaps with things like Kinect things will change if there are more ways to interact with devices. Again, only time will tell.

The future of the PC

To summarize the summary of a summary: The death of the PC has been greatly exaggerated. The ol grrl still has som kick in er… Shis juss putten some new dress on…

And remember’, Panic IS an option’. Perhaps not the best one but…

Windows 8 Consumer preview ISO and VS11 Beta downloads

In case you were looking for these:



The VS11 downloads also include the new TFS Express Beta…

Launch apps as Admin without prompt

This is a tip intended to ease the pain of continuously having to click the ‘Yes’ prompt when you want to launch an app in ‘Admin mode’.

The trick is to use the built-in Windows Task scheduler.

1. First you create a new task (not a basic task) and specify a name e.g. ‘CommandLine’ plus check the ‘Run with highest privileges’ check box.

2. On the actions tab you add a ‘Start a program’ action and select the executable e.g.’C:\Windows\System32\cmd.exe

3. Optionally under the Settings tab you can choose ‘Run a new instance in parallel’so you can run multiple instances of the app if required.

4. Click OK to create the task

Next you create a Windows shortcut (say on the desktop by right clicking and choosing new -> Shortcut)

1. Specify the following as the ‘Target’: e.g.  ‘C:\Windows\System32\schtasks.exe /run /tn CommandLine
Pay attention that the last parameter must match the task name.

2. You may want to manually select an icon for the shortcut as it won’t select the app icon by itself.

Now if you click (double-click) the shortcut a brief command line window before opening your app (in admin mode) – without prompting you! One big disadvantage is that you cannot pass command line parameters this way so launching say notepad with a specified txt file this way won’t work.

Of course, it would have been easier if MS built in a way you can choose (at your own risk) which apps you would like to launch in admin mode without prompting. There is a potential security risk in allowing functionality like that but if they wanted to it could be done with a big warning dialog at the start – that tells you you’re doing this at your own risk. It could use something like signing the required exe with a local (only) certificate to mark it trusted only on the local machine or generating a hash that gets stored in an encrypted system location or something, to tell the OS that particular exe can be trusted (when launched). The way to set up this hash and stuff would need to be a secure process in itself (requiring a ‘human’ user input) and letting you jump through a couple of hoops – once off. The idea is to allow only that particular exe on the particular machine as trusted. Copying it to another machine or changing it would require setting up the ‘trust’ again. Just an idea… (throwing a hint… to Microsoft)

Rule of odds

Well, this is not strictly a rule per se but it does feel like one. After reading one of the comments on a Tomshardware article I think this deserve some mentioning 🙂

If you judge the Windows releases throughout the years (well averages..) you get this:

win 95: bad
win 98: good (yes actually SE)
win me: bad
win xp:good
win vista: bad
win 7: good
win 8: i think you can guess it now…

Apparently this concept works for Star Trek movies as well 😉 And I was hoping for a ‘good’ next Star Trek movie…