Saturday 18 December 2010

Virtualising Delphi 6 PC (Activation Errors)

At work we had a very old machine that we used for Delphi 6 development. The time had come to upgrade it. We decided that the most flexible way of upgrading it was to virtualise it.

Below are the steps we followed to virtualise the Delphi 6 machine.

  1. Take a clone of the machine. We use CloneZilla which is free and does the job fine.
  2. Create a new virtual machine and restore the clone onto it. We use XenServer as our virtualisation server.
  3. The virtual machine will not start up and may show BSoD. This is because of a mismatch between the physical machine hardware and virtual hardware. Repair the Windows XP installation by booting from a Windows XP CD and repairing the current installation.
  4. Boot into the virtualised machine and apply all updates and Citrix client tools
Everything was hunky dory up until step 4.

I clicked on the Delphi 6 icon to start it up and I got an activation request with three options on it.
  1. Activate over the web
  2. Activate over phone /email
  3. Activate later
I chose activate later and Delphi closed down. So I tried activate over the web. This option timed out. Finally I chose Activate over phone / email. This looked more promising. I had to go to a website and enter my activation details. I entered all required information and and clicked next. The activation wizard said Delphi had been activated and registered but then behind it there was another box stating that the registration / activation information was missing or corrupt.

To test if it was something to do with my user account I decided to activate Delphi 6 on another user account. This worked fine. So it was something to do with my account...

I rang Embarcadero and they said they only way to solve this was to run D6RegClean.exe from the bin directory of the Delphi6 install. This would have removed all my third party tools and and all my customisation. So I decided to keep this option as a last resort!

From my conversation with Embarcadero I relialised that a registry entry was to blame so I delved into the murky world of Windows registry.

I found that there were three keys related to licensing
LMKEY and LMLIC had correct information about my keys. So the only other one to investigate was LM. This was a binary number and looked like is was automatically generated.

(Please note: Messing around with the registry can break your system only do it if you know what your doing)
So I took a backup of the registery and removed LM key. I tried registering again and it worked!

Hope this helps someone.

Thursday 30 September 2010

[Software] Wake on Lan - Magic Packet

Over the past month we have had a lot of problems setting up some some software that included integrated Wake on LAN. The software wouldn't wake any of our computers up even though the computers BOIS settings were correctly set to enable Wake on LAN.

During this time I was inspired to create my own Wake on LAN (WOL) programme so that I could prove that our network wasn't to blame for the computers not waking up.

WOL Magic Packet v.1 Download Here

WOL - Magic Packet has the following features

  • Send Wake on LAN packets to a number of computers at the same time by using computer MAC addresses.
  • Retrieve computer MAC addresses by supplying a range of ip addresses. The start and finish ip address must be in the same ip subnet. i.e. Both should have the same first three numbers.
  • Save and retrieve lists of computer MAC addresses to a text for later use
  • Run saved MAC address lists from the command line by using the format
WOLMagicPacket.exe [path to list of mac addresses file]

Please let me know what you think about this.

Wednesday 8 September 2010

[Tip] Find duplicate rows in spreadsheet

A number of times in the past I have helped users to remove duplicates rows from excel or calc spreadsheets.

Below is the process I have used.

  1. Order the spreadsheet by the columns from which you want to remove duplicates. This will group together all duplicate rows.
  2. Create a calculation in an empty field to concatenate all fields that are being duplicated. For example '=CONCATENATE(A1,B1,C1)'. With A,B,C being the columns that contain duplicate data.
  3. Create another calculation in an empty field to compare each rows concatenated result column with the previous rows concatenated result column. For example '=if(D1=D2,"duplicate","unique")'. With D being the column with the concatenate calculation in it.
This will give you a list of "duplicates" and "uniques" to identify if a row is unique or a duplicate of the previous row. This list can be filtered on "unique" or copied to a new sheet to get a set of unique rows.

Below is an example google spreadsheet to give an idea of the columns required accomplish the task



Hope someone finds this useful

Wednesday 1 September 2010

New look website

I have decided to freshen up the look and feel of the website.

Please let me know what you think.

Wednesday 18 August 2010

PXE Boot Thinstation using Windows 2003

At work we run DHCP on windows servers. We wanted to stop using Thinstation CDs for for our PC thin clients so that configuration changes were easier to deploy and to eliminate the need for CD drives on our PC thin clients.

We had already created our Thinstation image so we had all the thinstation files that we required. Instead of going into the ISO folder (for CDs) go into the PXE folder and save all the files in the folder for later. (Let me know if you need more information about this)

Here is how we did it!

1. Install a TFTP server from TFTPD32
Make the settings look as follow
Remember to set the location of TFTP files. Copy the previously saved PXE files into this location on the server.

The folderlocation should look as below.

2. Add the following settings to your DHCP servers

Two extra [server options] need to be added in the DHCP console.066 is the name of the computer where the TFTP Server is installed.
067 is the relative path to the thinstation pxe boot files. (I created a thinstation folder in my TFTP directory but this is optional).

3. Configure the bios on the PC thin clients to boot from the network with PXE.

Hope this helps someone

Thursday 8 July 2010

OpenFiler Tips and Tricks

I have recently setup a OpenFiler server at home. The main reason was because I have maxed out all local hard drive connections on my main PC. I researched abit and it came down to FreeNAS or OpenFiler.

I opted for OpenFiler because I have used FreeNAS before and thought it was great except for the fact that it was based on FreeBSD, an OS I'm not that familiar with. OpenFiler is based on Linux and has a reputation for having higher transfer rates than FreeNAS. I was thinking of using iSCSI so I went with OpenFiler

The setup of OpenFiler was quite straight forward but here are a few tips that may help people new to the system.

Problem:
When using the Web Interface for OpenFiler, the Volumes page does not load up

Issue:
This is a known issue that OpenFiler has with floppy disk controllers.

Solution:
Disable the floppy controller in the BIOS
--

Problem:
Hard drives with partitions from other operating systems are detected in OpenFiler but cannot be used for storage.

Issue:
OpenFiler must format all hard drives before they can be used as storage

Solution:
Run the following command to format the hard drives that cannot be used

parted /dev/hdX mklabel gpt

Where /dev/hdX is the name of the hard drive
--

Problem:
Client computers using Microsoft iSCSI Initiator to connect to iSCSI targets on the OpenFiler server get the following error when trying to discover targets.

"CHAP secret given does not conform to the standard. Please see system event log for more information."

Issue:
The password used for CHAP Authentication is not the correct length. The password needs to be between 12 and 16 characters.

Problem:
Set the CHAP Authentication password in OpenFiler so that it is between 12 and 16 characters.

Useful links

Sunday 16 May 2010

[Tip] Quick and Dirty Repetitive Command Line Tasks with Excel

At work we had to create folders for all our users. We didn't want to create each folder manually so we went through the following set to accomplish the task (It took about 10 minutes from start to finish):

1. Get a list of users from Active Directory.
We have a SQL Server Database with a linked table to Active Directory so we queried that to get a list of usernames.

2. Copy the list of users to a blank excel document into Column B

3. Type "mkdir" in to Column A.

4. Fill down Column A to the number of username rows.

5. Save the excel file as type "Text file (tab delimited)" to your desktop

6. Close excel and rename the created file so that it has the extension ".bat" at the end.

7. Move the file to the folder where you want to create the username folders.

8. Double click on the file to run it.

9. With in a few seconds you should have a list of folders called the names of your users.

This kind of procedure has a great many uses. Please let me know if you have used a technique like this and how you used it.

This procedure should work in a similar way on Linux / Macintosh and Windows alike.

Thursday 22 April 2010

[Tip] Use GMail to sign up to Web Apps multiple times with same email account

Gmail 512px - See description for downloadI needed to sign up to Twitter for a website I helped develop. I have already set up multiple twitter accounts and used email addresses that I regularly use.

I was looking for a way of using the same email for multiple twitter accounts and found a link which explained that google email considers xxx@gmail.com and xxx@googlemail.com as the same address.

Straight away that gives you a two for one deal on your google email. It doesn't end there. Google email addresses also ignore dots (.) when emails are sent to them. So xx.x@gmail.com is considered the same as xxx@gmail.com. So all variations will end up in the same google mailbox

There are many applications for this feature including spam control however for me it makes it a lot simpler when signing up for web applications like twitter where your email address has to be unique for each account.

Hope this helps someone.

Tuesday 13 April 2010

[Tip] Grant Executor Permissions on All Stored Procedures

This tip works on SQL Server 2005 or above

Most people say that all sql code should be kept separate from your application in the database layer as stored procedures. Whenever I have done this in the past I have had to go into each stored procedure and set the execute permissions for the users. This is time consuming and error prone.

I realised that there must be an easier way of setting the execute permissions so that it only had to be set once for the database after a bit of searching I found the answer.

You just have to run the following sql code on the database.

/* CREATE A NEW ROLE */
CREATE ROLE db_executor

/* GRANT EXECUTE TO THE ROLE */
GRANT EXECUTE TO db_executor


This code creates a new role called 'db_executor' then grants executor permissions to the role.

After running this code you can add a user to the new role by running the following sql code.

EXEC sp_addrolemember 'db_executor', 'sqlusername'


Important Note:
The only draw back with this method of assigning execute permissions is that the user will get permissions to execute any stored procedure already created or created in the future.

Monday 8 February 2010

[Fix] Keyboard not working on Windows login screen

Apple KeyboardI had an issue with my main development machine at work last week. It was booting up fine but as soon as it got to the Windows XP login screen the keyboard froze up. I could still move the move and the computer was still responsive.

I did a bit of troubleshooting and found that the keyboard worked correctly in the BIOS and also worked fine in a Linux Live CD. I could even remote desktop onto the machine and it the keyboard worked correctly. I tried a few different keyboards and the computer did the same. So I thought it was a driver issue...

To fix it I tried to do a check disk (chkdsk /r) from the recovery console on Windows XP installation CD. This is done by running the Windows XP installation CD, choosing Repair Console (option 'r') from the first option screen and then typing 'chkdsk /r' when the console loads.

Check disk took about 1 - 2 hours to complete and showed that it had fixed some errors. So I exited the console and rebooted the machine however the problem remained.

Finally I found a post by Ryan. T. Adams called Keyboard Not Working Due to Missing Or Corrupt Drivers (Code 39). This had a step by step guide of how to fix the problem.

Below are the steps I followed to fix the problem. Please note this method requires editing the registery so make a backup of the registry and be careful.


  1. Go to your Start menu and click “Run…”
  2. In the Run box that opens, type “regedit” and press Enter.
  3. In the new window that opens, click the “Edit” menu, then “Find.”
  4. In the find filed, type “kbdclass” and press enter.
  5. The registry editor will now search for any key that has “kbdclass” in it. What you are looking for is any that have a name of “UpperFilters” and a data of ” something_random_here kbdclass” You may need to go to “Edit,” “Find Next” if the search finds something else first.
  6. Once you find the key, double click on it, and edit the text so that it includes only “kbdclass”. Press OK.
  7. Continue searching (using the “Edit” and “Find Next” menu) until you have found and edited all of the “UpperFilters” keys. Again, all should have a data filed that includes only “kbdclass”.
  8. Close the registry editor.
  9. Go to the device manager, find your keyboard in the list (which should still be reporting a “Code 39″ error), and uninstall it.
  10. You should then restart your computer, and with any luck, your keyboard will work upon rebooting.


Thanks to Ryan for this great fix

Wednesday 27 January 2010

My Thinstation Configuration

I have been asked for our thinstation configuration file a few times so here it is. I will try to explain the customisations we have done in the comments

# --- Network configuration

# Give a different name to each PC
# NET_HOSTNAME=MyThinclient

# We are using a cd based system so we don't use tftp server for config
NET_FILE_ENABLED=Off

# If you want to use a DHCP server, comment out these params:
#NET_USE_DHCP=Off
#NET_IP_ADDRESS=192.168.0.70
#NET_MASK=255.255.255.0
#NET_GATEWAY=192.168.0.1
#NET_DNS1=192.168.0.1
#NET_DNS2=192.168.0.21
#NET_DNS_SEARCH=cartoons.org.nz

# --- Session Options
#
# Note: # is a number equal to or greater than 0
#
# SESSION_#_TITLE Title description for SESSION. Needed for replimenu.
# SESSION_#_TYPE Package type, choose beetwen:
# - vncviewer Start vncviewer in X
# - rdesktop Start rdesktop in X
# - x Start x-terminal session (xdm)
# - ssh Start ssh client in linux console
# - telnet Start telnet client in linux console
# - ica Start Citrix ICA client in X
# - tn5250 Start AS400 client in linux console
# SESSION_#_SCREEN Display number to run the X server on
# SESSION_#_AUTOSTART ON Application will be executed immediately at startup
# OFF Application will appear in a menu to be started manually
# SESSION_#_WORKSPACE Workspace to run program on in a window manager
# SESSION_#_type_SERVER IP address/hostname of the server
# SESSION_#_type_OPTIONS Command line options for the session type


# Individual Session Settings, override defaults
#
# IMPORTANT: Make sure you minimum have a SESSION_0. Otherwise you will get an error
# on boot. You may have additional sessions: SESSION_1, SESSION_2 ...
# SESSION_0 is on ctrl-alt-F3
# SESSION_1 is on ctrl-alt-F4
# ... etc.


# If you only have one session, it is a good idea to uncomment this line:
AUTOSTART=On

# Typical Windows 2000 session
#SESSION_0_TITLE="Windows 2000 terminal server"
#SESSION_0_TYPE=rdesktop
#SESSION_0_RDESKTOP_SERVER=192.168.1.1
#SESSION_0_RDESKTOP_OPTIONS="-u 'fred'"

#SESSION_0_TITLE="NewCitrixServer"
#SESSION_0_TYPE=ica
#SESSION_0_ICA_SERVER=xxx.xxx.org.uk

# Important: don't insert spaces in the session title
# ica.xxx.org.uk is a dns round robin address for all citrix servers in farm
SESSION_0_TITLE="CitrixServerAppDesktop"
SESSION_0_TYPE=ica
SESSION_0_ICA_APPLICATION_SET="Desktop"
SESSION_0_ICA_SERVER=ica.xxx.org.uk

# Typical Windows 2003 Server session, with True-color and sound redirection
# Note: use '-a 16' and '-a 24' to get true-color with Windows 2003+
# Older servers don't support these color depths, wrong settings may cause connection to fail.
#SESSION_1_TITLE="Windows 2003 terminal server (16 bit color depth)"
#SESSION_1_TYPE=rdesktop
#SESSION_1_RDESKTOP_SERVER=192.168.1.1
#SESSION_1_RDESKTOP_OPTIONS="-u user -p password -a 16 –r sound"
#Example on USB Printer Redirection for Rdesktop
#SESSION_#_RDESKTOP_OPTIONS="-r printer:usb='DYMO LabelWriter 400 Turbo'"

# Important: don't insert spaces in the session title
#SESSION_0_TITLE="CitrixServer"
#SESSION_0_TYPE=ica
#SESSION_0_ICA_APPLICATION_SET="Microsoft Word"
#SESSION_0_ICA_OPTIONS="-username donald -password qwak"

# ICA: Instead of connecting to an "application set",
# you can directly connect to a specific server desktop
# Important: don't insert spaces in the session title
#SESSION_3_TITLE="CitrixServer"
#SESSION_3_TYPE=ica
#SESSION_3_ICA_SERVER=ICA

#SESSION_#_TITLE="Unix server"
#SESSION_#_TYPE=x
#SESSION_#_X_SERVER=192.168.1.2
# Default is '-query'
##SESSION_#_X_OPTIONS="-indirect"
# You should set also "SCREEN_X_FONT_SERVER", below

#SESSION_#_TITLE="VNC server"
#SESSION_#_TYPE=vncviewer
#SESSION_#_VNCVIEWER_SERVER=192.168.1.2

#SESSION_#_TITLE="Telnet server"
#SESSION_#_TYPE=telnet
#SESSION_#_TELNET_SERVER=192.168.1.2

#SESSION_#_TITLE="SSH server"
#SESSION_#_TYPE=ssh
#SESSION_#_SSH_SERVER=192.168.1.2

#SESSION_#_TITLE="AS400 server"
#SESSION_#_TYPE=tn5250
#SESSION_#_TN5250_SERVER=192.168.1.2
# Use this option to specify keyboard map
#SESSION_#_TN5250_OPTIONS="map=280"
# Other options
#SESSION_#_TN5250_OPTIONS="env.DEVNAME=JDevBox1 +underscores env.TERM=IBM-3477-FC"


# --- General Options
#
# AUDIO_LEVEL Audio Level for sound, 0-100
# KEYBOARD_MAP Keyboard layout
# TIME_ZONE Used to set time zone on TS client by entering the UTC offset.
# This can be set automatically if the appropriate dhcpc option is selected
# (Option 2, time offset in seconds)
# RECONNECT_PROMPT This displays the reconnection/shutdown options for when a session is ended
#
# OFF No reconnect prompt
# ON Reconnect prompt will be displayed
# MENU Shows a menu with a shutdown and reconnection option
# MENUXX As MENU option, but the XX is a time period in minutes.
# After XX minutes shutdown will occur unless the reconnect option
# is choosen

AUDIO_LEVEL=67

# Look inside BuildFiles\build.conf* file for a list of the supported KB layouts
# important to change the keyboard map / timezone to your local settings else time is wrong in the session. Reconnect set to "Shutdown or Reconnect"
KEYBOARD_MAP=en_gb
#TIME_ZONE="UTC-00:00"
TIME_ZONE="GMT+0BST,M3.5.0,M10.5.0"
RECONNECT_PROMPT=MENU01


# --- X Server Options
#
# SCREEN_RESOLUTION Screen resolutions available in the workstations
# SCREEN_COLOR_DEPTH Number of bits per pixel (8,16,24)
# SCREEN_HORIZSYNC Monitor horizontal sync frequency in Khz.
# If left blank Xorg will try to detect with DDC
# SCREEN_VERTREFRESH Monitor vertical refresh frecuency in Hz.
# If left blank Xorg will try to detect with DDC
# SCREEN_X_FONT_SERVER IP address or hostname of the font server for X
#
# Screen Saver Settings
# SCREEN_BLANK_TIME Minutes to X session goes blank
# SCREEN_STANDBY_TIME Minutes to X session goes into standby mode
# SCREEN_SUSPEND_TIME Minutes to X session goes into suspend mode
# SCREEN_OFF_TIME Minutes to X session turn off
#
# MOUSE_PROTOCOL Mouse protocol type (Microsoft, PS/2, etc.)
# (mouse is autodetected, use this only if it fails)
# MOUSE_DEVICE Mouse device: /dev/ttyS0 -> COM1
# /dev/ttyS1 -> COM2
# /dev/ttyS2 -> COM3
# /dev/ttyS3 -> COM4
# /dev/psaux -> PS/2 mouse port
# /dev/input/mice -> USB mouse (needs USB package)
# MOUSE_RESOLUTION Mouse resolution
# MOUSE_ACCELERATION Mouse acceleration
# X_NUMLOCK Set numlock state on boot
# X_COOKIE Will set X Cookie if specified

#SCREEN_RESOLUTION="800x600"
SCREEN_RESOLUTION="1024x768"

SCREEN_COLOR_DEPTH="24"

#SCREEN_HORIZSYNC="30-64"
#SCREEN_VERTREFRESH="56-87"

#SCREEN_X_FONT_SERVER=192.168.1.2:7100

SCREEN_BLANK_TIME=10
SCREEN_STANDBY_TIME=20
SCREEN_SUSPEND_TIME=30
SCREEN_OFF_TIME=60

# Mouse acceleration: We found in testing that the speed of the cursor was much slower that fat clients so we added following options to try and speed it up.

#MOUSE_PROTOCOL=PS/2
MOUSE_PROTOCOL=IMPS/2
#MOUSE_DEVICE=/dev/psaux
#MOUSE_RESOLUTION=100
#X_NUMLOCK=Off
MOUSE_ACCELERATION=1/8
#X_COOKIE=36d71ab65c10ef065702c111a3d31593


# --- Citrix ICA Specific Options
#
# GLOBAL Settings
#ICA_USE_SERVER_KEYBOARD Use default server keyboard, otherwise use KEYBOARD_MAP
# variable
#ICA_BROWSER_PROTOCOL Broswer protocol, can be HTTPonTCP or UDP
#
# APPLICATION SET settings
#ICA_ENCRYPTION Encryption level for ICA
# Valid Settings Below
# "Basic"
# "RC5 (128 bit - Login Only)"
# "RC5 (40 bit)"
# "RC5 (128 bit)"
# "RC5 (56 bit)"
#ICA_COMPRESS Compression, On/Off
#ICA_AUDIO Audio, On/Off
#ICA_AUDIO_QUALITY Audio Quality, Low, Medium, High
#ICA_PRINTER This will turn on ICA autocreate printers, see printer section
# for details, On/Off
#
# NOTE: You must have the lpr package included for this option
# to work.
#
#ICA_APPLICATION_SET Published Application (Not needed if using
# ICA_SERVER)
#ICA_SERVER Server to Connect to (Not needed if using
# ICA_APPLICATION_SET, but needed if the ICA-Masterbrowser
# is not on the local network.)
#ICA_WFCLIENT_type_specific This allows you to specify specific config file details for global ica
# parameters any parameter can be changed with this setting. An example of this is
# ICA_WFCLIENT_CLIENTDRIVE="On"
# See your application manual for documentation on the settings which
# can be used.

#ICA_USE_SERVER_KEYBOARD=Off
ICA_BROWSER_PROTOCOL=HTTPonTCP
#ICA_SERVER=
#ICA_ENCRYPTION=Basic
#ICA_COMPRESS=On
#ICA_AUDIO=On
#ICA_AUDIO_QUALITY=Low
#ICA_PRINTER=off
#ICA_SEAMLESS_WINDOW=Off


# --- LP Server Printing Options
#
# PRINTER_0_NAME Workstation Printer Name, Can be Any Valid Name
# If you have turned ICA_PRINTER=ON then this is the
# name of the printer driver
# PRINTER_0_DEVICE Workstation printer device (if not specified devices
# are not loaded).
# /dev/printers/[0-2] for parallel ports
# /dev/ttyS[0-3] for serial ports
# /dev/usb/lp[0-2] for USB printers
#
# PRINTER_0_TYPE P for parallel, S for serial, U for USB printer
# PRINTER_0_OPTIONS Serial port options.
# PRINTER_1_* See PRINTER_0_*
# PRINTER_2_* See PRINTER_0_*
# PRINTER_3_* See PRINTER_0_*

#PRINTER_0_NAME="parallel"
#PRINTER_0_DEVICE=/dev/printers/0126
#PRINTER_0_TYPE=P

#PRINTER_1_NAME="serial"
#PRINTER_1_DEVICE=/dev/ttyS1
#PRINTER_1_TYPE=S
#PRINTER_1_OPTIONS="speed 38400 -imaxbel"

#PRINTER_2_NAME="usb"
#PRINTER_2_DEVICE=/dev/usb/lp0
#PRINTER_2_TYPE=U


#ICA Autocreate Printer Example
# Local printers can be a bit hit and miss (better with parallel printers).
# Must give thinstation computer a static ip address on dhcp server then
# install printer on print server with static ip address and correct drivers
# and finally change the port in printer settings from
# 9100 to 9101 ONLY IF printer is usb.
PRINTER_0_NAME="parallel"
PRINTER_0_DEVICE=/dev/printers/0
PRINTER_0_TYPE=P

PRINTER_1_NAME="usb"
PRINTER_1_DEVICE=/dev/usb/lp0
PRINTER_1_TYPE=U



Thinstations configuration can be a bit daunting initially but once you get the hang of it, it mostly makes sense.

Please send me your comments or questions.