Archive for January, 2009


Continuous Ping


Sometimes when testing network connectivity to a server on the local LAN or a web site I use the ubiquitous PING to do the job.  If I need to do it repeatedly I tend to write a quick DOS batch file (a text based script with a file extension of BAT or CMD).

For example this script would repeatedly ping localhost – the name used for the machine the script is being run on.

@echo off
Ping -n 1 localhost

A few years ago I even extended this to include a ping count but it didn’t really add much. I decided it would be more useful to have something that at least gave an indication of how many “good and bad” pings had occurred. At the same time I also found that I wasn’t always necessarily at my computer as I might be tinkering with cables and other networking gear so having some sort of audible cue as to how the pings were going.

I put together the following VB Script to do just this. It hasn’t been tested extensively and I’m sure that there could be a bit more validation. When the script is run it asks for the host to ping and a time at which to stop pinging. It then opens up an Internet Explorer window that displays the information about the pinging.

Option Explicit

'- Number of PC speaker beeps on ping successes/failures
'- Milliseconds of pause between pings
Const PAUSE_MS = 200
'- Milliseconds pause before automatically closing the progress window
Const AUTO_CLOSE = True
Const FINAL_PAUSE = 5000

'Variable definitions
Dim strHost
Dim dtEnd
Dim objShell, objExplorer
Dim intSuccessfulPingCount, intUnsuccessfulPingCount

Set objExplorer = CreateObject("InternetExplorer.Application")

objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Left = 0
objExplorer.Top = 0
objExplorer.Width = 400
objExplorer.Height = 400
objExplorer.Document.Body.Style.Cursor = "default"
intSuccessfulPingCount = 0
intUnsuccessfulPingCount = 0

'If we don't have a host then ask for one
If Wscript.Arguments.Count < 1 Then
	strHost = InputBox("Please enter the host to ping", "Enter Host", "localhost")
	strHost = Wscript.Arguments(0)
End If

'Double check what we have
If Len(strHost)  0
	'Carry out the ping
	If Ping(strHost, False) = True Then
		'Ping successful
		intSuccessfulPingCount = intSuccessfulPingCount + 1
		'Ping unsuccessful
		intUnsuccessfulPingCount = intUnsuccessfulPingCount + 1
	End If
	UpdatePings "<p><b>RUNNING...</b></p>"

objExplorer.Document.Body.Style.Cursor = "default"
	UpdatePings("<p><b>AUTO CLOSING...</b></p>")
	Wscript.Sleep FINAL_PAUSE
	UpdatePings("<p><b>PING CYCLE COMPLETED</b></p>")
End If

'Update the display of pings
Sub UpdatePings(p_strSuffix)
	Dim strDisplay

	strDisplay = ""

	strDisplay = strDisplay & "<p>"
	strDisplay = strDisplay & "Finish pinging @ "
	strDisplay = strDisplay & dtEnd
	strDisplay = strDisplay & "<br />"
	strDisplay = strDisplay & "Currently ... "
	strDisplay = strDisplay & Now()
	strDisplay = strDisplay & "</p>"

	strDisplay = strDisplay & "<hr>"

	strDisplay = strDisplay & "<p>"
	strDisplay = strDisplay & "<table border='0'>"
	strDisplay = strDisplay & "<tr>"
	strDisplay = strDisplay & "<td><font color='green'>Successful pings</font></td>"
	strDisplay = strDisplay & "<td><font color='green'>"
	strDisplay = strDisplay & intSuccessfulPingCount
	strDisplay = strDisplay & "</font></td>"
	strDisplay = strDisplay & "</tr>"
	strDisplay = strDisplay & "<tr>"
	strDisplay = strDisplay & "<td><font color='red'>Unsuccessful pings</font></td>"
	strDisplay = strDisplay & "<td><font color='red'>"
	strDisplay = strDisplay & intUnsuccessfulPingCount
	strDisplay = strDisplay & "</font></td>"
	strDisplay = strDisplay & "</tr>"
	strDisplay = strDisplay & "</table>"
	strDisplay = strDisplay & "</p>"

	strDisplay = strDisplay & "<hr>"

	strDisplay = strDisplay & "<p>"
	strDisplay = strDisplay & "Auto Close Enabled: "
	strDisplay = strDisplay & AUTO_CLOSE
	strDisplay = strDisplay & "</p>"

	strDisplay = strDisplay & "<hr>"

	strDisplay = strDisplay & p_strSuffix

	objExplorer.Document.Body.InnerHTML = strDisplay
End Sub

'This function pings the specified host
Function Ping(p_strHost, p_boolDisplay)
	Dim objPing, objStatus

	Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery ("select * from Win32_PingStatus where address = '" & p_strHost & "'")

	For Each objStatus in objPing
		If IsNull(objStatus.StatusCode) or objStatus.StatusCode0 then
			Ping = False
			If p_boolDisplay Then
				WScript.Echo "Status code is " & objStatus.StatusCode
			End If
			Ping = True
			If p_boolDisplay Then
				Wscript.Echo "Bytes = " & vbTab & objStatus.BufferSize
				Wscript.Echo "Time (ms) = " & vbTab & objStatus.ResponseTime
				Wscript.Echo "TTL (s) = " & vbTab & objStatus.ResponseTimeToLive
			End If
		End if
End Function 

'Beep the PC speaker a number of times equal to the p_intBeeps parameter
Function Beep(p_intBeeps)

	Dim objShell, intCount, strCommand

	'Check we have a valid number of beeps not fool proof but it will do for now
	Beep = False
	If IsNumeric(p_intBeeps) Then
		If p_intBeeps > 0 Then
			Beep = True
		End If
	End If

	If Beep Then
		'Build the command string to run
		strCommand = "cmd /c echo"
		For intCount = 1 to p_intBeeps
			strCommand = strCommand & " " & chr(007)

		'Run the command in the background
		Set objShell = Wscript.CreateObject("wscript.Shell")
		objShell.Run strCommand, 0

		Beep = True
	End If
End Function

There are also a few options in the script to specify numbers of beeps for successful and unsuccessful pings as well as auto closing of the Internet Explorer window and lengths of pauses between pings and before auto closing the window.


Google May Harm Your Computer


Like almost everyone else with an Internet connection on the planet i use Google a lot.  Today though they seem to be having problems.  Everything I’m searching for seems to have an associated warning – this site may harm your computer.

I signed out of iGoogle, tried and  All were affected and notably Google itself seems to be unsafe…

Is Google self harming?

Is Google self harming?

Following the link give some additional details of what this may mean, but the diagnostic page is perhaps under a bit of stress at the moment.

Global Warning

Global Warning

Better luck next time

Better luck next time

I think Google may be a bit poorly today.  Hopefully it’ll be back to normal soon….  I’m not sure what a world on the Internet without google to guide the way would be like.  I don’t like the sound of that just now.


NoteTab Clip – Use Empty File


A little clip I like to use in NoteTab is one for ensuring that I have an empty file.  I usually call it using the ^!FarClip command from a standard library before I dump out the results of something where I always want it to be separate.  It’s a very short and sweet little clip – just paste it into your favourite little clip library.

H="_Use Empty File"
;If the current document isn't blank then
;open a new blank document
!If ^$GetTextSize$ = 0 Skip
^!TOOLBAR New Document

Also note that the underscore on the header. This ensures that the clip can’t be run separately but only from another clip. You can remove this if you like, but if you want to run it separately I’d suggest a quick glance and pressing the new document button or pressing CTRL+N might be faster.


NoteTab Clipping – Detect Parameter Passing


When working with NoteTab clips I like to be efficient and reuse clips just like programmers do with functions, subroutines, code libraries, etc. So one little thing I like to use when dealing with some clips is a conditional statement that allows the clip to work out if it was called from another clip with a parameter.

To accomplish this we’re actually going to use something that the NoteTab Clip help file recommends against – converting 4 (decimal) to a character using the ^$DecToChar()$ function. ASCII(004) is an end of transmission character, but it turns our that we can test against this on the parameter place holder. Just trying to measure the size as zero when a parameter is passed for example curiously gives a length of two characters.

^!If ^& > ^$DecToChar(4)$^$DecToChar(4)$ PARAM_PASSED Else NO_PARAM

The two go to labels used here show the logic. PARAM_PASSED is where a parameter has been passed and NO_PARAM is where no parameter was passed.

This snippet of code is useful because it can be used for example at the start of a clip that could be run manually by a user taking in a parameter through an input box. It can also be used at the end in determining how to deal with a result – display it, insert it, pass it back in the %RESULT% variable, etc.

Please note that the code does not distinguish between a clip called with no parameters from another clip and a clip run manually. Of course if the clip is called from another clip using a dummy parameter it could be used as a crude way of doing this.


Sticky Note Sorting


Ever sorted sticky notes (affinity diagramming) on a wall and then had to copy it all down?  Well perhaps StickySorter from Microsoft Offics Labs might be just the thing you need.  Combine it with an electronic whiteboard like MIMIO or a projector and a gyroscopic/wireless keyboard & mouse and you can really get to work.  With Microsoft Surface on the horizon it could be even more natural and just ever so slightly Minority Report … but not everything’s perfect.


Screen Capture


For a simple screen shot taking tool, Lightscreen is a free piece of software that sits in the system tray and can assign hot keys to capturing screen areas as well as the usual desktop and active window.  It can also be set to dump out direct to file.

There’s also a much more powerful tool called Screenshot Captor that not only takes screen shots, but can also add additional graphics to them.  It can also help in presentations by highlighting/dimming screen areas.  Again it’s free but you can also donate to the author if you like it.


PowerPoint – Mastering the canvas


Every presentation these days involves Microsoft PowerPoint.  After a while no matter how much multimedia you add to it, your presentation can still look a bit dull and boring.  In order to make your next presentation a bit different why not try pptPlex – a PowerPoint plugin that rebuilds a set of slides into a single ‘zoomable canvas’.

I saw this used by James Senior of Microsoft at the Misco Expo in October 2008 on a presentation about SBS, EBS and MS Server 2008.  It worked really well and added a new dimension to the way in which the presentation was delivered.  It also allowed him to skip around and to show areas that were collections of slide that fit together like a jigsaw but could then be zoomed in.


Grab Web Page into NoteTab Text Editor


NoteTab is a favoured text editor of mine and for a number of years I’ve used it for working with web pages and coding up HTML, PHP, Javascript and the like.  One of the best features of NoteTab (beyond the light version being free to download) is its powerful scripting language – creating what is known as NoteTab Clips.

Grab Web Page clip inputs

Grab Web Page clip inputs

One of my favourite clips is one that provides a basic integration with a command line utility to download a web page without having to go into your web browser and view it.

So if you don’t already have them download the following free pieces of software:

  • NoteTab Light – text editor with scripting capabilities.
  • wGet – command line utility for downloading files from the Internet.

The two clips below should be copied and pasted into an appropriate clip library in NoteTab (see the NoteTab help file on how to do this – it’s very straight forward).  Run the “Grab Web Page” clip and after specifying what URL to download, where to download it to, how to display it (open the downloaded file, copy the file content into a new file or insert the file content at the current cursor position) and what log file to log the activity to.

H="Grab Web Page"
;Initialise variables
^!Set %FETCH_URL%=^?[URL of web page to retrieve=]
^!Set %OUTPUT_PATH%=^?[(T=D)Directory to download file to=c:wGet Output]
^!Set %INSERTION_TYPE%=^?[(T=C)Downloaded file==_Open|Copy into new file|Insert at cursor]
^!Set %LOG_PATH%=^?[(T=S;F="Log Files (*.log)|*.log")File to log download progress to=c:wGet Outputoutput.log]
^!Set %WGET_PATH%=^?[Path to wGet.exe=C:Program FilesCommand line Utilitieswget.exe]

;Remove trailing backslash if it exists - wGet doesn't like these
^!If "^$StrCopyRight("^%OUTPUT_PATH%";1)$"="" NEXT Else SKIP
^!Set %OUTPUT_PATH%=^$StrDeleteRight("^%OUTPUT_PATH%";1)$

;Create the output directory
;(If it exists it won't do any harm)

;Fetch page
^!Set %FETCH_OUTPUT%=^$GetOutput("^%WGET_PATH%" -P"^%OUTPUT_PATH%" -nv -o"^%LOG_PATH%" "^%FETCH_URL%")$

;Get the name the retrieved file was named as
^!Set %OUTPUT_FILE_PATH%=^$GetFileText(^%LOG_PATH%)$
^!Set %OUTPUT_FILE_PATH%=^$StrDeleteLeft("^%OUTPUT_FILE_PATH%";^$Calc(^$StrPos("-> ";"^%OUTPUT_FILE_PATH%";TRUE)$+3)$)$
^!Set %OUTPUT_FILE_PATH%=^$StrCopyLeft("^%OUTPUT_FILE_PATH%";^$Calc(^$StrPos(""";"^%OUTPUT_FILE_PATH%";TRUE)$-1)$)$
^!Set %OUTPUT_FILE_PATH%=^$StrReplace("/";"";"^%OUTPUT_FILE_PATH%";TRUE;TRUE)$

;Output the contents of the downloaded file
^!If "^%INSERTION_TYPE%"="Copy into new file" NEXT Else SKIP
^!Clip "New From Text" ^$GetFileText(^%OUTPUT_FILE_PATH%)$
^!If "^%INSERTION_TYPE%"="Insert at cursor" NEXT Else SKIP
^!InsertFile ^%OUTPUT_FILE_PATH%

H="_New From Text"
^!Menu File/New
^!InsertCode ^&

Word – Creating Sample Text


Microsoft Word has a little known feature (unless you happen to have read Microsoft Knowledgebase Article 212251 of course) that allows you to create large amounts of sample text using what’s in effect an inline macro command.  Microsoft Word 2007 has a wider range of macro commands than previous versions, but I’ll describe the 2007 versions here.

In each case the parentheses can take two optional parameters.  Both are positive integers and they specify the number of paragraphs to create and the number of lines per paragraph respectively – e.g. =rand(p,l)

Each of the three commands inserts a different text sample as follows:


On the Insert tab, the galleries include items that are designed to coordinate with the overall look of your document. You can use these galleries to insert tables, headers, footers, lists, cover pages, and other document building blocks. When you create pictures, charts, or diagrams, they also coordinate with your current document look.

You can easily change the formatting of selected text in the document text by choosing a look for the selected text from the Quick Styles gallery on the Home tab. You can also format text directly by using the other controls on the Home tab. Most controls offer a choice of using the look from the current theme or using a format that you specify directly.

To change the overall look of your document, choose new Theme elements on the Page Layout tab. To change the looks available in the Quick Style gallery, use the Change Current Quick Style Set command. Both the Themes gallery and the Quick Styles gallery provide reset commands so that you can always restore the look of your document to the original contained in your current template.


The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.


Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.

Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus.

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.

These are useful commands when you are demonstrating working with documents in Word or are just looking for some text to test your latest macro or mail merge with and just need some text quick.


Meeting Scheduling


When scheduling meetings with people who don’t share a common calendar system I favor the use of Doodle.  However you might be interested to know that Meet-o-matic are offering 1,00 free registrations for their latest more advanced beta version for online registrations.