Avoiding using hard-coded pathnames in scripts

Another gem gained from my anonymous colleague is the use of the %0 environment variable (which returns the current command name in the same way as %1, %2, etc. return any arguments passed to the command) to avoid using hard coded paths in scripts. For example, %0\..\ refers to the directory in which the file is located, and can be used where a pathname is required, but the drive letter may vary, e.g. %0\..\scripts\ (where the scripts folder could be on any available drive, but always the same drive as the calling command).

Scripting the deletion of registry keys and values

One of my colleagues (who wishes to remain anonymous) gave me a great tip this morning – how to delete registry keys and values using a .REG file.

To delete a value, set its contents to – in the .REG file, e.g.

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\MyKey]
"MyValue"=-

Or to delete a key, add a – sign after the leading [ in the .REG file, e.g. [-HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\MyKey]

Apparently this works on all version of Windows from Windows 2000 onwards, although I’ve only tried it with Windows XP Professional.

How Outlook rules work

This morning, as part of an e-mail migration, I was looking at a scenario where I needed to divert all inbound e-mail messages from one (Exchange Server) mailbox to another (Microsoft Mail) mailbox, unless the message originated from the target mailbox. I couldn’t implement this in Active Directory as it only supports a simple divert of all incoming messages to another recipient (and so couldn’t handle the additional complexity of excluding certain messages), but the rules and alerts functionality within Microsoft Outlook is more flexible.

One potential issue was around where Outlook stores information relating to its rules – because I need to create the rule using Outlook on one PC and remove it from another.

In this case, everything was fine, because this particular rule ran server-side (and hence didn’t rely on Outlook being active in order to execute); but it’s not always that simple – some rules rely on Outlook client functionality.

The Slipstick website includes comprehensive information on how the rules functionality is implemented, both for standalone Outlook clients and for Outlook clients connected to Exchange Server computers.

Finding that elusive control character code

I use Blogger to create and update this blog (because it’s quick and easy, whilst still giving me a level of control over layout etc.).

Unfortunately, the graphical interface in Blogger strips out some non-alphanumeric characters, such as the pipe symbol (|) meaning that a little bit of HTML massage is needed from time to time.

Whilst editing such a post today I came across a collection of useful tables for ASCII codes, HTML codes, control codes and conversion.

Getting Tivoli to work on a Windows XP computer with a personal firewall enabled

I’m working with a client on a Windows XP standard operating environment (SOE) that includes service pack 2 (with Windows Firewall enabled). They use IBM Tivoli for remote control, inventory and software distribution but IBM do not currently support the Tivoli client on SP2 machines and some work was needed to get it working across the firewall. For reference, here are the firewall exceptions that were needed:

  • IBM Tivoli Inventory Collector (C:\Program Files\Tivoli\lcf\inv\SCAN\wepmcoll.exe);
  • IBM Tivoli JRE (C:\Program Files\Tivoli\lcf\bin\w32-ix86\tools\jre\1.3.0\bin\java.exe);
  • IBM Tivoli Management Agent (C:\Program Files\Tivoli\lcf\bin\w32-ix86\mrt\lcfd.exe);
  • IBM Tivoli Mobile Console (C:\Program Files\Tivoli\lcf\dat\1\mobile\mobile.exe);
  • IBM Tivoli Mobile Console Distribution (C:\Program Files\Tivoli\lcf\dat\1\cache\bin\w32-ix86\TME\mobile\epnewdist.exe);
  • IBM Tivoli Remote Control Target (C:\Program Files\Tivoli\lcf\PCREMOTE\w32-ix86\tgt\eqnrcmai.exe);
  • IBM Tivoli Software Distribution Engine (C:\Program Files\Tivoli\lcf\dat\1\cache\bin\w32-ix86\TME\swdis\spde\spd_eng.exe).

Theoretically these would be the same whatever the personal firewall product in use; however all of the above should be configured as application exceptions (Tivoli uses randomly generated ports under certain circumstances and so simple packet filtering exceptions would be inappropriate). If the firewall in use only handles packet filtering, then you may have more difficultly getting this working (you may need to open big holes in the firewall to cover a range of possible ports – in this case I would suggest using the Windows Firewall instead as it does offer application filtering – see my earlier post about choosing whether to run the Windows Firewall, a third party firewall, or both).

Obviously installations of Tivoli (as for most enterprise management products) vary according to the features in use and if the exceptions above do not completely resolve the issue, James Dawson gave me the following advice:

  1. Run netstat -ano | find "LISTENING". This will give a list of TCP ports that are listening for connections and the last column of the output is the ProcessID (PID) of the process actually listening. You can then use the PID to find what ports the Tivoli process(es) are running on, and then add these ports to the exceptions.
  2. Use the PIDs from the output of step 1 to check whether Tivoli is using any UDP ports: netstat -ano | find "PID" (repeat for each Tivoli PID).

Ctrl-Alt-Delete is a verb!

“Ctrl-Alt-Delete (kun.trohl-awlt-duh.LEET) idiom. A metaphoric mechanism with which one can reset, restart, or rethink something. -v.”

This, and many more definitions of both everyday and obscure terms may be found at the Word Spy website, which describes itself as:

“Devoted to lexpionage, the sleuthing of new words and phrases. These aren’t stunt words or sniglets, but new terms that have appeared multiple times in newspapers, magazines, books, Web sites, and other recorded sources.”

For us computer-types (or geeks as the site often refers to us), there is the Tech Word Spy website.

Free network scanning tools

Network scanning tools are a bit of a grey area. For those of us who need to keep systems secure, they are valuable tools. But for those who are unaware of their existence, they are a means for a would be attacker to scan your network in search of vulnerabilities.

The eEye Digital Security website has a number of free utilities which may be of interest, in particular the nmapNT and LibnetNT utilities, which are Win32 ports of the similarly named Unix tools.

Handy script for determining when a user last logged on

I recently came across a handy script which examines a Windows NT/2000/XP/2003 computer or an Active Directory domain controller to read out the last log on time for each user. By piping the output to a text file, it could be useful for sorting and identifying redundant user accounts.

Automatically appending the time and date to text files using Notepad

I found this little nugget of information which may be useful for anyone looking to automatically append the time and date to a text file each time it is edited with Notepad.

According to the Made with Notepad campaign website, it works for versions of Notepad from Windows 95 onwards, and I have tested it on Windows XP Professional (SP2).

Simply start the text file with .LOG and save. From then on, the current date and time will be added to the end of the document each time it is opened in Notepad.

Introducing the ultra personal computer (uPC)

Howard van Rooijen‘s reply to my post about installing the “Energy Blue” theme on a computer running Windows XP Professional got me looking at James Clarke’s blog, where I found a post about the OQO Model 01 ultra personal computer.

I haven’t seen a real one yet but this looks like a cool device – no cut down operating system – just full Windows XP Professional (not CE) on a 1GHz pocket-sized PC with 256Mb RAM, a 20Gb hard disk and a slide-out keyboard. It can also connect to peripheral devices including video (1280×1024 pixels), audio, Ethernet, FireWire and USB (only 1.1 at this time) using a docking cable. For more details, see the OQO website.

Back in February I was at a product demonstration for the Antelope Technologies modular computer (similar to the OQO, but the computer “core” is a hard-disk-sized unit which plugs in to a variety of shells for ruggedised, portable computing). More details of the modular computer are available at the Antelope Technologies website but the OQO looks more like a business tool, whereas I can see the modular computer taking off for industrial/commercial use.

The only problem for me right now is the $1999 price tag (plus options)…