Archive for category Windows XP

Autohotkey – Applications that exit gracefully give you consistent backups

I have a Weighbridge application at work that runs on top of Paradox databases. When you exit via the GUI say by clicking the cross in the top right or {ALT} {F4} it does the right thing and cleans up after itself as it closes. If you simply say pskill ProcessName from a batch file then it leaves a heap of temporary paradox *.db files.

The problem is to try and get a backup of the application in a consistent state. Simply killing the application from a batch file doesn’t work.

Enter autohotkey. Autohotkey is feature rich enough so that you can program it to send any key sequence or mouse click to a window and code it to handle different things that occur in the application.

So I am using it to exit the application or any of it’s windows just before a backup.

; auto hot key script to exit weighbridge as if it was a user
; so weighbridge cleans up temp c:\weighbridge\*.db files
; james mcdonald
; 5:23 PM 10/03/2009
; this is called from backup_wb.bat
; it tries to cover all the use conditions where a user would leave different windows open
 
; Password Error Dialog
IfWinExist Error
{
    WinActivate
    Send {Escape}
}
 
; username / password prompt
IfWinExist Password
{
    WinActivate
    Send !{F4}
}
 
IfWinExist Vehicle List
{
    WinActivate
    Send !{F4}
}
 
IfWinExist Carrier List
{
    WinActivate
    Send !{F4}
}
 
IfWinExist Incomplete List
{
    WinActivate
    Send !{F4}
}
 
IfWinExist Customer List
{
    WinActivate
    Send !{F4}
}
 
IfWinExist Source List
{
    WinActivate
    Send !{F4}
}
 
IfWinExist Destination List
{
    WinActivate
    Send !{F4}
}
 
IfWinExist Transaction List
{
    WinActivate
    Send !{F4}
}
 
; a common report I'm not sure if there needs to be more for reports
; but should do
IfWinExist Customer by Item Report
{
    WinActivate
    Send !{F4}
}
 
IfWinExist Report Menu
{
    WinActivate
    Send !{F4}
}
 
IfWinExist WeighBridge
{
    WinActivate
    Send !{F4}
}
 
IfWinExist WeighBridge
{
    WinActivate
    Send !{F4}
}
 
IfWinExist WeighBridge
{
    WinActivate
    Send !{F4}
}
 
; snooze for 4 seconds before continuing backup_wb.bat
Sleep 4000

No Comments

Cygwin Telnet Client

For some weird reason when attempting to run the Windows version of telnet under Cygwin it returns to a prompt without connecting.

So you need to install the Cygwin Package that contains a telnet client which is: inetutils

Run the cygwin setup.exe and choose inetutils.

Installing inetutils gives you the following utilities:

ftp.exe
iu-config
rcp.exe
rlogin.exe
rsh.exe
syslogd-config
talk.exe
telnet.exe
tftp.exe
ftpd.exe
inetd.exe
rexecd.exe
rlogind.exe
rshd.exe
syslogd.exe
talkd.exe
telnetd.exe
tftpd.exe
uucpd.exe

I used cygcheck.exe to list the above:

cygcheck.exe -l inetutils | grep bin | cut -d/ -f4

Note: If you haven’t restarted your cygwin terminals and you are running bash you will need to run hash -r to get your terminal to forget about the windows telnet.exe and use cygwins version.

2 Comments

Virtual Desktops or Workspaces on Windows XP

If you use Windows XP at work, but Linux at home, you may be missing the multiple desktops feature that Linux provides . http://virtuawin.sourceforge.net/ is the answer.

I don’t use the “group similar taskbar buttons” Windows XP feature but find multiple workspaces a handy way of dividing your “work” applications (Outlook, Microsoft Office etc) from “home” applications (Dia, QCAD, PuTTY, Thunderbird, Firefox etc).

Once you install VirtuaWin, use the Windows Key and the left, right, up & down arrows to move between workspaces.

, , , ,

No Comments

Ever wanted to right click on a file or folder and then copy the path? – Heres how

At work I get phone calls from users asking where file or folder X is.

Instead of starting into explaining the path to the user and then explaining which key is the backslash key, I have found it easier to copy the path into an email and send it to them. I have a small script I attach to the right click context menus for file and directory objects

Context Menu Get File Path

Clicking on “Get File Path” brings up a vbs script input box from which I can copy the path from.

Get File Path Input Box

How it works

This vbs script is copied to C:\Windows\System32 (I have saved it with a txt extension so you need to rename it back to getFilePath.vbs.

This registry file contains the entries to get the option to appear on your right click menu (again you need to rename it to getfilepath_install.reg and double click it to make it work.)

Disclaimer: Please go to the support.microsoft.com website and read the disclaimer on any of their knowledge base articles about editing the registry. Because it applies here. i.e. you can render your computer unuseable if you edit the registry in the wrong way.

No Comments

Using Knoppix and the dd utility to restore a WinXP partition Image to a Hard Disk

These are my notes on how I successfully restored a Windows XP image I took of a partition.

I can’t remember how exactly I took the partition image of the Windows XP installation. I can remember the following points

  • I was dual booting at the time and I needed the XP partition to increase disk space for linux
  • Image was taken from within Linux
  • It was taken with either dd if=/dev/hdb1 of=imagename.img or cp /dev/hdb1 imagename.img
  • I confirmed a successful partition copy using md5sum /dev/hdb1 and then md5sum imagename.img. The resulting MD5 sums need to be exact
  • The resulting image was stored on hard disk uncompressed

The restore was to a machine which was dedicated to Linux. It has two harddisks hda and hdb. I used a bootable Linux CD with all the utilities I needed to make the changes. I used PING but ran in to trouble with it’s gui and ended using the shell it provides. You could just as easily use Knoppix which has all the same utilities.

  1. Boot using CD
  2. Map drive to computer that is hosting the disk image. Use mount -t smbfs //hostname/share /mnt/mountpoint -U remoteuser%password
  3. Using fdisk or cfdisk. Delete the Linux partitions on one disk. I chose hda which is a 20GB HDD
  4. Find out how many kilobytes the image file is. Using ls -lk imagename.img. I came up with a figure of 8193119 kb (approx 7gb)
  5. Create a new primary partition using fdisk. Start the partition at the default cylinder 1 and then specify a size using the format +8193119K. Set the partition type to hex 07 which equates to NTFS/HPFS. Set the partition bootable flag to be on. Write the new partition to disk and exit fdisk
  6. using dd restore the data to the new partition. dd if=imagename.img of=/dev/hda1 bs=64k
  7. The dd will take about 45 minutes to an hour for an image that (7.8GB) size
  8. When dd returns. reboot the computer using a Windows XP installation CD. Type r to get into the recover console… Note: you will have to know the administrator password for the XP installation. If you don’t you will need to use a Linux utility to reset the XP admin password. I think it’s called ntpasswd.
  9. In the windows XP recovery console I ran fixmbr and fixboot. This replaces the master boot record that until now was a linux one. I don’t know which command had the desired effect. I ignored the warnings that came up about making my installation unbootable
  10. The above gave me a bootable Windows XP installation. I was prompted to re-activate Windows. Which I did.

After getting a bootable Windows XP installation I noted that 8GB is too small for a windows XP installation with all the bells and whistles so I decided to enlarge the partition to the full size of the disk as follows. I have also put the following in it’s own post because they can be performed as too separate operations

  1. Boot from my trusty Linux boot CD again
  2. Run fdisk and delete the Windows XP partition and recreate a partition the full size of the disk
  3. Remember to reset the partition to a type of 07 and set the bootable flag
  4. run ntfsresize --info /dev/hda1 to get info on the disk
  5. run ntfsresize -v -s <SIZEINBYTES> /dev/hda1
  6. I first tried to specify the partition size in the MB and ntfsresize complained that I was trying to resize to a size bigger than the partition. Looking at the output carefully showed that I was specifying a partition with more bytes in it than the physical partition had even though they displayed the exact same MB size I assume this was due to rounding so I switched to bytes and made it exactly same as the partion bytes and ntfsresize ran with out complaint.
  7. Once this was complete I rebooted back into Windows and it ran a disk check.

Restoration and Disk Space Upgrade Complete!

No Comments