Faster Numbering of OmniFocus Tasks

I wrote up how I’m numbering tasks in OmniFocus, but I’ve now modified the Keyboard Maestro recipe so it’s just a touch faster.

Here’s a screenshot:

Updated, faster recipe for numbering tasks in OmniFocus
Updated, faster recipe for numbering tasks in OmniFocus

I’ve also since created a separate recipe in Keyboard Maestro for each key Project I have in OmniFocus, each with it’s own .txt file that it refers to. This lets me do

,,taskadmin

and it’ll spit out “(Admin #7)” or if I type

,,taskcrm

it’ll spit out “(CRM #15)”.

What Version of Microsoft Installer?

Sage ACT! 2011 and 2012 require Microsoft Installer 4.5 or better to be installed. I like to know prior to running the Sage ACT! installer just which version is installed as the Sage ACT! installer will install it if it’s required and then do a reboot. And we all know that reboots are often not welcome.

Thus for one an all’s installation enjoyment, here is the code for determining just which version of the Microsoft Installer is present.

@Echo off
:: Created by Ben Hamilton ACT! CRM Certified Consultant
:: to display which version of the Microsoft Installer is installed.
:: http://ben.hamilton.id.au
Echo set args = WScript.Arguments >fvi.vbs
Echo Set fso = CreateObject("Scripting.FileSystemObject") >>fvi.vbs
Echo WScript.Echo fso.GetFileVersion(args(0)) >>fvi.vbs
Echo Wscript.Quit >>fvi.vbs
for /f "skip=2 " %%G IN ('cscript fvi.vbs %systemroot%\system32\msi.dll') DO (Set MSIVersion=%%G)
Echo Microsoft Installer %MSIVersion:~0,3% is installed.
del fvi.vbs /q
pause

Hope you find it as useful as I do.

How to find your external ip address from the command line

I often need to know what the external IP address for a client is. Thus I’ve cobbled together the following script. Simply copy the code below into externalip.cmd and when run from the command prompt it will do two things for you:

  1. the script will display the external IP address
  2. the script will set the environment variable ExternalIP to be whatever that IP is


@echo off
:: Find out what the External IP address is
:: Create the .vbs file first
Echo Option Explicit >externalipaddress.vbs
Echo Dim http : Set http = CreateObject( "MSXML2.ServerXmlHttp" ) >>externalipaddress.vbs
Echo http.Open "GET", "http://whatismyip.org", False >>externalipaddress.vbs
Echo http.Send >>externalipaddress.vbs
Echo Wscript.Echo http.responseText >>externalipaddress.vbs
Echo Set http = Nothing >>externalipaddress.vbs
:: run the resulting .vbs script and set the enviroment variable
for /f "skip=2 " %%G IN ('cscript externalipaddress.vbs') DO (Set ExternalIP=%%G)
:: Display the enviroment variable
Echo External IP is %ExternalIP%
:: tidy up and remove the temp file
del externalipaddress.vbs /q

Let me know if you find this useful, or if you can improve on it I’d love to hear from you.

Using registry values in scripts

I’m often writing scripts to do stuff. It makes my job easier. I’ve often wanted to be able to script the discovery of registry values in the Windows Registry.

Thus here is a short example on using the vanilla windows command line to find the value of a Windows registry key. From my testing these commands are all present by default in Windows XP, Vista, 7, Server 2003 and Server 2008.

Assume we want to find the Microsoft Windows Common Files directory. Using `Regedit` we can find that here: `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\CommonFilesDir`

So the first thing we want to do is query the registry, we do that with the command line tool `reg` as follows ([more about reg][]):

[more about reg]:http://www.petri.co.il/reg_command_in_windows_xp.htm
“Read up on how to use the reg command for more than just a query”

`reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion /v CommonFilesDir >1.tmp`

This will spit out the following into the text file `1.tmp`:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion
CommonFilesDir REG_SZ C:\Program Files\Common Files

However, this isn’t of much use in a script. Really, we just want the value of the folder itself, not all the extra info.

So what we do is use the command line tool ‘findstr’ which essentially is a windows regex tool ([more about findstr][]). We use it to do this:

[more about findstr]:http://www.netexpertise.eu/en/windows/findstr-an-alternative-to-grep.html
“Read up on findstr – regex goodness on windows by default”

`findstr /r REG_SZ 1.tmp >2.tmp`

This spits out just the line that contains REG_SZ and puts it into the text file `2.tmp`. Now that we’ve just just the one line, we want to strip the first 32 characters off it. We do this by first setting it as an enviroment variale and then trimming it down using the following two commands ([more on set][]):

[more on set]:http://www.computing.net/answers/windows-2000/use-file-contents-to-set-variables/63174.html
“Using file contents to set enviroment variables”

`set /p CommFiles=<2.tmp` And then we shorten that ([more on trimming][]): [more on trimming]:http://www.dostips.com/DtTipsStringManipulation.php "Read up on using set to trim environment variables" `set CommFiles=%CommFiles:~32%` Then we can echo the result to the screen using: `Echo The Common Files directory is: %CommFiles%` And here it is all in one easy to copy set: --- Set CommFiles=C:\Temp reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion /v CommonFilesDir >1.tmp
findstr /r REG_SZ 1.tmp >2.tmp
set /p CommFiles=<2.tmp set CommFiles=%CommFiles:~32% Echo The Common Files directory is: %CommFiles% --- With a little editing I'm sure that you can turn this to your own uses, pulling out the value of registry keys and using them in script files. You're not limited to this registry key, you can use it to access all sorts of registry keys. Please do tell me what uses you put this to. Enjoy.