So I had a problem on Windows in that I have lots of directories that are named correctly but I wish the files under them to be uniformly named.
The solution was to use PowerShell, which is an extremely effective scripting tool for Windows, especially if you come from a UNIX shell background.
There is actually quite a lot of documentation available for it and rather than go into detail I will simply show you the script:
#
# RenameDirectoryFiles.ps1
#
param( [string[]]$paths )
Set-PSDebug -Strict
foreach ( $path in $paths ) {
if ( !(Test-Path $path -PathType Container) ) {
Write-Error "'$path' doesn't exist or isn't a directory"
exit 1
}
$i = 0
Get-ChildItem $path | sort FullName | foreach {
$tmp = "{0:000}" -f $i
$ext = $_.Extension
$newname = "$path - $tmp$ext"
Rename-Item $_.fullname $newname
$newname
$i = $i + 1
}
}
So the usage is extremely simple:
RenameDirectoryFiles.ps1 'My Directory'
After which all the files under ‘My Directory’ will be renamed to ‘My Directory – 000.fileextension’.
I was recently pointed to the English and Polish pages for the MS Business Productivity. The most striking thing about the difference between the pages is that one depicts a white individual in place of a black individual. What could be the purpose of altering the image, surely it isn’t racism, after all the Chinese individual is still in place.
Strange what goes through the brain of MS Business Productivity.

Polish Alternative

English Alternative
I was recently asked if it was possible to monitor the Event Log for a single event and ensure that it was occurring regularly. It is rare that I handle Windows scripting and when I do I normally find myself cursing it, haha! In this case we want to ensure that a print server is constantly printing through the day, we expect that at least 1 print job will occur every 15 minutes, if not then we’d like a warning. Obviously this check should only run during work hours.
So the first step is relatively simple, access the Event Log and look for a single event by its event code.
set objWMIService = GetObject("winmgmts:\root\cimv2")
set colEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where Logfile = 'System' and EventCode = 10")
What we did here was grab all the events with event code of 10 (a print job!). So if we count the number of events within a range then we will have basically completed a huge part of the work.
So next step is to make an interval that will be 15 minutes back from whatever time is current.
set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
dtmStartDate.SetVarDate DateAdd("n",-15,Now()),True
And applying that into our statement:
set colEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where Logfile = 'System' and EventCode = 10" _
& " and TimeWritten >= '" & dtmStartDate & "'")
This means that we are now collecting the events that only occurred within the last fifteen minutes. So what next, well we need to have a statement to pass to BigBrother to indicate success or failure. Fortunately enough I have another script which monitors the cluster (thanks to the awesome DeadCat repository) and it has some code to help place the file that BigBrother collects.
const HKLM = &H80000002
strBBExtPathNew = "SOFTWARE\Quest Software\BigBrother\bbnt\ExternalPath"
strBBExtPathOld = "SOFTWARE\BigBrother\bbnt\ExternalPath"
set oReg = GetObject("winmgmts:\root\default:StdRegProv")
oReg.GetStringValue HKLM,strBBExtPathNew,,strExtPath
if isNull(strExtPath) then
oReg.GetStringValue HKLM,strBBExtPathOld,,strExtPath
end if
if isNull(strExtPath) then
WScript.Quit
end if
Read more…
I regularly suggest AVG as a free anti-virus solution. I have actively used it for well over 8 years now and have never found myself struck by a virus it couldn’t clean or stop.
Recently two annoyances have crept into AVG. The first is easily solvable, a corrupt update.
If you get a message saying “Invalid update control CTF file”. This means that AVG has found that its update file is corrupt. The quickest way to sort this is to delete the update files:
- Open the “AVG User Interface”
- Tools > Advanced settings (via the menus)
- Then “Update” and “Manage”
- Press “Delete temporary update files”
- Run the update again.
Easy enough to fix.
The second annoyance is the Link Scanner. I can understand what it is attempting to do but in my preference I do not wish AVG to add additional traffic to my already clogged internet connection! The trick to sorting this is to remove the link scanner at installation. This might mean uninstalling AVG to reinstall but to get rid of Link Scanner its worth it. Simply select a “Custom installation” and then when it gets to “Component Selection” uncheck LinkScanner .. done!
So I recently showed you how easy it was to install VMware under Redhat. Now lets look at how easy it is to install Windows XP as a guest OS.
First you will need to get a hold of your Windows XP CD ready for the installation, put it into the CD-Rom.
Open up the VMware console and select File > New > Virtual Machine. This will open us the Wizard that will walk us through the installation. Click Next and then select Typical and again click Next. Select Windows XP from the list of operating systems available, you can normally leave the location as its default but remember that you need at least 8Gb (the default) per guest OS that you are installing. I normally choose a bridged network setup, with most network layouts now there is a DHCP server and its easy to add another IP to your network. You can however set it to share its IP with the host system. As you go through the next steps, selecting the defaults is normally good enough. You can tweak if you wish but I am happy to settle for the defaults.
Once all that is complete it will make 8Gb of space available for your install. At this point you can start the guest system and it will then boot from the Windows CD. Continue as normal through the Windows install and you should wind up with a Windows XP installation.
Once it is all up and running I do highly suggest that you install VMware Tools, available by doing VM > VMware Tools. The installer should then pop up and start. You should see the VMware icon in the lower corner by the clock.
Poke around and have fun. All the other OS installs are carried out in much the same manner.
That’s it, a working XP guest installation!