Wednesday, December 14, 2011


For getting info from AD in a text format, I'm finding LDP.exe which is part of the Windows Server 2003 tool-set VERY HELPFUL.

Typically I need to list members in AD groups and in AD Users & Computers you cannot export the lists.

LDP.exe, once bound to the domain can perform these simple queries and then you can grab the text output :)

I had to change the buffer and page size in the options to be able to get full results for queries that return a lot of text.

Simple enough, and free :)

Tuesday, October 18, 2011

Folder Polling Script

A neat little script which checks a specified folder (here its C:\Presentations) for the addition of a new file every 5 seconds (WITHIN 5 WHERE) .
Then the script checks for a certain file type, here Powerpoint or web page/link, and then triggers the app accordingly to run this file.
When a new file is detected, the app currently running is closed and a new one started.

I have a server connected to a plasma display, and this script allows users to drag a file into a shared folder, and the server will display the latest file dragged in to the plasma.

(It uses the relevant switches for powerpoint presentation mode - POWERPNT.EXE /S, and  Internet Explorer kiosk mode - iexplore.exe -k.)

Set objShell = CreateObject("Wscript.Shell")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & _
        strComputer & "\root\cimv2")
    'set poll time and location in the next line
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
    ("SELECT * FROM __InstanceCreationEvent WITHIN 5 WHERE " _
        & "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
            & "TargetInstance.GroupComponent= " _
                & "'Win32_Directory.Name=""c:\\\\Presentations""'")
    Set objLatestEvent = colMonitoredEvents.NextEvent 'waits until next event - next file put into folder.
    strNewFile = objLatestEvent.TargetInstance.PartComponent
    arrNewFile = Split(strNewFile, "=")
    strFileName = arrNewFile(1)
    strFileName = Replace(strFileName, "\\", "\")
    strFileName = Replace(strFileName, Chr(34), "")
    strFileName = Chr(34) & strFileName & Chr(34)
    'check for file type and if ppt or htm then close program to allow for new application instance with file
    'filter for ppt or iexplore
    If Right(strfilename,6) = ".pptx" & Chr(34) Or Right(strfilename,5) = ".ppt"  & Chr(34) Then
    objShell.Run("POWERPNT.EXE /S " & strFileName)
    ElseIf Right(strfilename,6) = ".html"  & Chr(34) or Right(strfilename,5) = ".htm"  & Chr(34) or Right(strfilename,5) = ".url"  & Chr(34) Then
    objShell.Run("iexplore.exe -k " & strFileName)
    End If
Loop 'keep going

Sub chkPPT
set service = GetObject ("winmgmts:")
bFlag = False
For each Process in Service.InstancesOf ("Win32_Process")
If Process.Name = "POWERPNT.EXE" Or = "iexplore.exe" Then
bFlag = True
End If
'check for file type of newly added file - do nothing if not ppt or ie8
If Not (Right(strFileName,6) = ".pptx" & Chr(34) Or Right(strFileName,5) = ".ppt" _
& Chr(34) Or Right(strFileName,6) = ".html"  & Chr(34) OR Right(strFileName,5) = ".htm"  & Chr(34) OR Right(strFileName,5) = ".url"  & Chr(34)) Then
bFlag = False
End If
'quit applications
If bFlag Then
strWmiq = "select * from Win32_Process where name='POWERPNT.exe'"
Set objQResult = Service.Execquery(strWmiq)
For Each objProcess In objQResult
intRet = objProcess.Terminate(1)
strWmiq = "select * from Win32_Process where name='iexplore.exe'"
Set objQResult = Service.Execquery(strWmiq)
For Each objProcess In objQResult
intRet = objProcess.Terminate(1)
End If
End Sub

Friday, September 30, 2011

When dates are not Excel friendly

I recently had an issue.

I have a report which exports into Excel. The date format from the report is US, and I work in the UK.
Excel tries to recognise the dates as UK, so for dates that fit (eg. month is 1-12) Excel gives me an incorrect date.  For dates that don't fit (eg. month is 13-31) then Excel doesnt recognise this as a date and this is formatted as plain text.

An example of this is below:
7/29/2011 7:23:26 AM
08/02/2011 05:45
These two dates should be 29/07/2011 and 02/08/2011 respectively. However the top one is formatted as text, whereas the bottom one is formatted as date (incorrect format in terms of UK to US!)
To rectify this issue I have the formula shown below (which assumes the cell A1 contains the top of the list of exported dates)
=IF(ISNUMBER(A1),DATE(YEAR(A1), DAY(A1), MONTH(A1)),DATE(MID(A1, FIND("/", A1, 4)+1, 4), LEFT(A1, FIND("/", A1)-1), VALUE(MID(A1, FIND("/", A1)+1, 2))))
This works exceptionally well.

A user came to me today with the same issue and following giving her this solution, I thought to blog this as being worth sharing.

Saturday, September 24, 2011

XBMC rip audio CD to mp3

Now my XBMC is up and running :

  • using wireless remote
  • all media on mounted USB share (Samba installed so I can access across home network eg configured as a NAS also)
  • using the Quartz skin currently
  • All music, video, movies, photos cataloged
We have loads of CDs in the attic not currently on the media drive, so i thought - 'let the ripping begin' ;-)

Strange however that XBMC baulked at ripping discs to .mp3 with the LAME encoder.

I have PuTTY set up so I can look around on a terminal level whilst XBMC is running, and also FileZilla to give me a nice GUI representation of the directories and files.

It seemed XBMC was creating the correct folder structure for my rip, but creating a 0 size file.

A fair amount (which is why I'm blogging this) of googling, and I found a reference to the fact that the native install of Ubuntu (which XBCM live runs on) does not have the lame endoer installed!

That'll be it then.

A quick sudo apt-get install lame at the terminal and....

...yeah - its ripping... :o))

(I say its ripping, and it is trying to.... me thinks need a less prehistoric DVD drive...:)

Thursday, September 1, 2011

Make an iPhone ringtone in iTunes 10

If you’ve made an iPhone ringtone before the process will be familiar to you. This will work the same on both Mac and Windows versions of iTunes 10:

Making the ringtone

Launch iTunes 10
Find and select the song you want to make a ringtone out of in iTunes 10
  Right-click on the song name and select ‘Get Info’

Then click on the Options tab
Select the playback period of the song that you want to ringtone to be, make sure it’s not more than 30 seconds – tick both boxes Start Time and Stop Time.
Now click “OK” and then right click on the song again, and select “Create AAC version” to create a new version of the song with the 30 second interval you specified
This will create a 30 second track.  Right click the original track and choose Get Info and go back to the Options tab – untick the Start Time and Stop Time boxes and click OK. This will keep the original track at its correct length.
Now click the new 30 second clip (it should be under the song).and drag the clip onto your desktop area.
If it doesn’t have the .m4a on the end, then you need to change some windows properties – see section at the end.
Right click it and choose Rename
Change the .m4a to .m4r
Click Yes when you get the next box.
Drag the file from your desktop back into iTunes
The file will now be added back into iTunes as a ringtone
Drag it into your iPhone Ringtones to sync it.

Change Windows Folder Settings
If you cant see the .m4a on the end of the file:

Open My Computer
Choose Tools | Folder Options
Click the View tab
Untick Hide extensions for known file types
Click OK
Now the .m4a should be visible.

Wednesday, June 22, 2011

No MODI in Office 2010! (get it from 2007)

Ok, so what I wanted to do was to run the Office 2007 install but to only install the MODI (Microsoft Office Document Imaging) component which for some reason has been excluded in Office 2010. This component amongst other things is an excellent .tiff editor.

I first tried using the Microsoft Office Customisation tool, by running the command setup.exe /admin (see

This has an excellent and straightforward GUI, and creates an .msp file which can then be pointed to using the command setup.exe /adminfile test.msp.

However, as my MS Office 2010 is installed and I will be using the license for 2010 to cover the 2007 MODI component (Microsoft's Office licenses are backwards compatible and can be used for the equivalent Office product in an earlier version provided that you are fulfilling the rest of the agreement in regards to number of installations) I did not have a product key for the 2007 install, and the use of the .msp then baulked as this needs to be supplied for the .msp file to go through, even though when I just ran the setup.exe manually it does NOT prompt for a key! (This is due to it seeing the install as an upgrade....

Anyway - I needed another solution, which I found with the setup.exe /config command. (

This involves copying the default config.xml and modifying it accordingly to your requirements. Below is the .xml I used to specify the MODI component only:

<configuration product="Enterprise">
<display accepteula="yes" completionnotice="yes" level="basic" suppressmodal="no">
<optionstate children="force" id="ACCESSFiles" state="absent">
<optionstate children="force" id="EXCELFiles" state="absent">
<optionstate children="force" id="GrooveFiles" state="absent">
<optionstate children="force" id="OneNoteFiles" state="absent">
<optionstate children="force" id="OUTLOOKFiles" state="absent">
<optionstate children="force" id="PPTFiles" state="absent">
<optionstate children="force" id="PubPrimary" state="absent">
<optionstate children="force" id="RMSFiles" state="absent">
<optionstate children="force" id="VisualStudio_PreviewServer_SPD" state="absent">
<optionstate children="force" id="WORDFiles" state="absent">
<optionstate children="force" id="XDOCSFiles" state="absent">
<optionstate children="force" id="SHAREDFiles" state="absent">
<optionstate children="force" id="TOOLSFiles" state="absent">
<optionstate children="force" id="MSOfficeDocumentImaging" state="Local">

Then I created a batchfile to run the setup.exe /config modi.xml command and hey presto - it works!

For a full list of options that can be configured in the xml I found most useful.

Thursday, April 21, 2011

Group Policy <> Registry

It's very helpful to be able to know the registry settings for group policy settings, to enable simple scripting to automate the settings.

Glad I found this link :o)