Skip to content

Category: Windows

Reading / parsing / writing .ini files in Powershell using XML

Last weekend I decided I needed to improve my Powershell scripting skills for a technical training I’m attending this week and started working on a script that could download, install and configure several applications unattended on demand. More on that script in a later blog post, for now I will focus on a specific feature I needed to script in order to make it all work.

One of the applications was still using a .ini file to configure some parameters of the tool and by nature of the script, I wanted to modify these values. One could use a search & replace method to change values in a .ini file (which is of course a simple text based file). In my search to easily parse a .ini file, I found several functions that could read the file and insert the values into hashtables. This makes values usable in a variable like $inihash[sectionname][keyname] = “value” however due to the nature of hashtables, it will sort the values in it’s hashtable by the hashvalue of it’s content. As most of us know, a hash value is different per object, per runtime, per system and will generate a unsorted mess. Inserting a .ini file with key1, key2, key3 might end up as key2, key1, key3 and there is no real way to circumvent this.

I was trying to work out the solution by working with hashtables, arrays and more .net objects in order to store the .ini values in a neat and sorted way. One could make a array with a hashtable with another nested array and hashtable but this would greatly increase complexity and reduce code friendliness as the $ini[section][key] notation would no longer function.

The other day I was casually discussing the problem with a fellow trainee and he suggested to (ab)use a XML object as a “storage box” as it would neatly allow nested constructions (section.key = value) and will remain sorted as it was imported (1,2,3 –> 1,2,3). First we would have to import a .ini file in to a XML object, later modify values and finally export the XML to a .ini file (sorted like the input .ini file).

Windows 7: Looking ahead at PDC

What can we expect to see of Windows 7 at the upcoming Microsoft Professional Developers Conference (or PDC) next week? I take a sneak peak at some of the features or improvements leaked, discussed or presented the last couple of weeks. This list isn’t accurate as Microsoft has deliberately been quiet about Windows 7 and its main features. Expect to hear about most of the following article next week when Windows 7 is officially uncovered to developers, IT pros, the press and the rest of the public at Microsoft PDC 2008!

Note: This article was written just before the official unveiling of Windows 7. The following notes and features are based on speculations, rumors, leaked information and screenshots. This article is made in partnership with Microsoft oriented weblog Credit given where credit is due.

Will Windows 7 get a cool new user-interface in terms of graphical overhaul?

Nope. Microsoft did officially state they won’t be changing the UI a lot (like they did when moving from Windows XP to Windows Vista) as, although very cool, most people get scared when seeing a new UI. The average user or users with less computer experience had some trouble adapting to the (rather minor, in my opinion) changes Windows Vista brought. So be prepared to be let down when it comes to the graphical appearance of the system itself if you were expected something better / newer / nicer. They are however putting some effort into making the experience more uniform across the system.

[, credit:]

I hate User Account Control (UAC) in Vista! Are they going to change that at all?

Nope. UAC as designed is a basic security and permissions/access design that should be implemented in every modern day operating system. Linux and Mac OS X have had this design for ages now, separating users from admins and raising privileges on the spot when needed. In some of the latest leaked screenshots, it showed Microsoft is however working on refining the user experience when using User Account Control. It showed a configuration panel allowing the user to set when and how the user should be notified of UAC notifications. Also note that Microsoft is very much paying attention to the general public on this issue. Based upon user input when Vista launched, Microsoft refined UAC in the Windows Vista Service Pack 1 release.

Will Windows 7 have a completely new and rewritten kernel powering the OS giving us more power?

Nope. Microsoft stated on their official Windows 7 blog they won’t be bringing a brand new kernel to the system as it’s simply not needed. The current NT kernel is just fine and, although people like to think otherwise, is fairly fast. They (Microsoft) did say they are brining improvements to the kernel as always. One should also consider the compatibility issues created when changing some as fundamental as the Windows kernel itself.

(Story continues after the break! Please read on for more information)