Wednesday, 25 June 2008

 

Event 7000, DS1410D service failed to start

Windows Event Viewer kept reporting error event 7000 each time I restarted my computer:

The DS1410D service failed to start due to the following error: 
The system cannot find the file specified.

The error is caused by Windows trying to load a file called DS1410D.SYS. This file is part of an application called FlexLM but since I've uninstalled FlexLM, the file has also been deleted.

The fix is find all instances of .../services/DS1410D/Start in registry and set it from 2 (Auto load) to 4 (disabled). See Microsoft KB 103000 article for more information.

Labels:


Sunday, 25 May 2008

 

Disable Vista Memory Diagnostic Tool

Vista has a Memory Diagnostic Tool which you can turn on to test your computer's memory when you restart it. Once it is enabled, this tool starts every time you restart your computer. Be warned: the Vista help system doesn't explain how to disable it!

After some Web searching, I found this tip:

- Open command prompt as Admistrator: by typing in start ''cmd'' right click the .exe file and then clicking on adminstrator. - Then typing in the console: ''bcdedit /bootsequence {memdiag} /remove'' press enter, after that you can restart your com. and it wont start

Labels: ,


Saturday, 24 May 2008

 

Fix Incorrectly Encoded Unicode Files with Python

The Problem

We had a lot of text files committed into our CVS repository as Unicode format. When these files were checked out later, we found that they weren't really text files nor Unicode files because CVS had only prepended two bytes to the start of these files, FF FE, but left only one byte for encoding each character. Some text editors such as Vim could open these files but other applications such as Notepad and Excel showed only gibberish.

Unicode Encoded Text in Files

Unicode is an encoding standard … for processing, storage and interchange of text data in any language. For the purpose of fixing this problem, we just have to know how to identify and write valid Unicode files.

We use two tools to experiment and visualize the effect of different encoding methods:

  1. Microsoft Notepad editor, because it can save text files using different encoding methods.
  2. GnuWin32 od utility to output the data in a file as byte values.

Open Notepad and enter this text: Hello World. Select the File / Save As menu item. In the Save As dialog, there are four encoding methods in the Encoding drop down list: ANSI, Unicode, Unicode big endian and UTF-8. Save the same text using each of the encoding methods into four files, say TestANSI.txt, TestUnicode.txt, TestUnicodeBigEndian.txt and TestUTF8.txt, respectively.

Examine the contents of each file using od:

>od -A x -t x1 HelloANSI.txt
000000 48 65 6c 6c 6f 20 57 6f 72 6c 64
00000b

>od -A x -t x1 HelloUnicode.txt
000000 ff fe 48 00 65 00 6c 00 6c 00 6f 00 20 00 57 00
000010 6f 00 72 00 6c 00 64 00
000018

>od -A x -t x1 HelloUnicodeBigEndian.txt
000000 fe ff 00 48 00 65 00 6c 00 6c 00 6f 00 20 00 57
000010 00 6f 00 72 00 6c 00 64
000018

>od -A x -t x1 HelloUTF8.txt
000000 ef bb bf 48 65 6c 6c 6f 20 57 6f 72 6c 64
00000e

The ANSI encoded file contains 11 bytes representing the characters you typed. The Unicode encoded files contain 24 bytes, starting with a two-byte BOM and using two bytes to represent each character. If the first two bytes are FF FE, then the two bytes are stored in low-byte, high-byte order. Conversely, if the first two bytes are FE FF, then the two bytes are stored in high-byte, low-byte order. Finally, when a file starts with byte EF BB BF, only one byte is used to encode each ANSI character and two or more bytes are used to encode non-ANSI characters (not demonstrated).

Fixing Incorrectly Encoded Files in Python

Now we know the format of a Unicode encoded file: it starts with FF FE and stores each character in low-byte, high-byte order. Our text files in CVS just have ANSI characters, so we just have to insert a 0 byte between each character, starting from the third byte. Julian W. wrote a short Python script that to do this. I don't have his code right now, so here's my version for correcting the Unicode encoding for a file:

import codecs
raw = map(ord, file(r'HelloBadUnicode.txt').read())
if raw[0] == 255 and raw[1] == 254 and raw[3] != 0:
  output = codecs.open(r'HelloFixedUnicode.txt', 'w', 'UTF-16')
  for i in raw[2:]:
    output.write(chr(i))
  output.close()

References

Postscript

I started with a more complicated piece of Python code using lists and generators:

from itertools import repeat
from operator import concat

raw = map(ord, file(r'HelloBadUnicode.txt').read())
if raw[0] == 255 and raw[1] == 254 and raw[3] != 0:
  output = file(r'HelloFixedUnicode.txt','w')
  output.write(chr(255))
  output.write(chr(254))
  for i in reduce(concat, zip(raw[2:], repeat(0, len(raw)-2))):
    output.write(chr(i))
  output.close()

But then I realised I just had to write a 0 byte after each ANSI character, so here's a simpler version:

raw = map(ord, file(r'HelloBadUnicode.txt').read())
if raw[0] == 255 and raw[1] == 254 and raw[3] != 0:
  output = file(r'HelloFixedUnicode.txt','w')
  output.write(chr(255))
  output.write(chr(254))
  for i in raw[2:]:
    output.write(chr(i))
    output.write(chr(0))
  output.close()

2008-05-25. I remembered that Python had no problems with writing Unicode files, resulting in the even simpler code in the body of this article.

Labels: , , ,


Friday, 23 May 2008

 

MDI Child Window Menu Shortcuts

I accidently moved PythonWin's Interactive window out of sight when I grabbed and dropped it with my mouse pointer. Restarting PythonWin didn't help because the position of the child window was stored in Windows Registry, so it remained hidden even after restarting PythonWin. I considered hacking Windows Registry to reset the child window's position, until I found the keyboard shortcuts to move the keyboard focus to a child window, show the System Menu and select the Move menu item.

Background: A child window is a window in a MDI application.

The keyboard shortcuts required to bring the child window back into view were:

  1. Move focus through child windows: Control+F6.
  2. Show a child window's System Menu: Alt+- (Alt Minus).
  3. Move child window: m, then press the cursor keys.

Keyboard shortcuts for Microsoft Windows applications: KB 126449.

Labels:


Sunday, 11 May 2008

 

Assign USB Drives to Folder

Each time you plug in a USB device to your Windows computer, Windows can assign a different drive letter to your device. If you have programs that rely on a fixed drive letter (e.g. portable applications on a USB drive or backups) or if you use more than one computer regularly, then it gets annoying to reset the programs' configuration after plugging in your drive or remember to plug in devices in a particular sequence. Assign USB Drives to Folder describes how to use Window's Disk Management to assign a fixed path to each device.

I wonder if it's possible to refer to a device using its volume name, which would make this method redundant?

Labels: ,


Thursday, 1 May 2008

 

More Uses of Getclip-Putclip

More uses of GnuWin32 / Cygutils tools getclip and putclip using this recipe: getclip | <command chain> | putclip.

A second recipe is (for /f %i in ('getclip') do @command %i) | putclip if command cannot be used in a pipeline. Two examples are basename (return name of file in a path string) and dirname (return path string without file name).

2005-05-01: Don't simply list transformations and filters that can be done with GnuWin32 tools, but ones where existing applications (e.g. Excel, Firefox, Outlook or Word) don't have an easy way to achieve a particular action.

Labels: , ,


Wednesday, 30 April 2008

 

Using Clipboard in the Command Line

GnuWin32 / Cygutils package has two tools for interacting with the Windows clipboard: getclip and putclip. The first copies text from the clipboard to standard output and the second copies text from standard input to the clipboard. These tools are useful when you want to process text from one Windows application before pasting the text into another application, in the following recipe: getclip | <filters> | putclip.

For example, I want to paste all DLL file names in a folder into a document:

  1. Navigate to the required folder using 2xExplorer browser.
  2. Type Alt+a to select all files.
  3. Type Alt+c to copy all file names. 2xExplorer copies the absolute path for each file.
  4. Start cmd.exe console.
  5. In cmd.exe console, enter: getclip | cut -d\ -fn | grep dll$ | putclip. cut is GnuWin32 tool which selects a column of data given a column delimiter (-d\ defines backslash) and field number (-fn defines column n). grep filters the output to only list files with "dll" in their name.
  6. Start editor.
  7. Paste the text in the clipboard in destination document.

Of course, you can do the same using Excel:

  1. Navigate to the required folder using 2xExplorer browser.
  2. Type Alt+a to select all files.
  3. Type Alt+c to copy all file names. 2xExplorer copies the absolute path for each file.
  4. Start Excel.
  5. Paste data in a worksheet column.
  6. Select all cells by typing Shift+Space.
  7. Open Convert Text to Columns Wizard by typing Alt+d+e.
  8. Select Delimited data type by typing Alt+d.
  9. Type Alt+n to go to page 2.
  10. Select Other delimiter by typing Alt+o, then enter "\" for paths.
  11. Type Alt+f run the wizard.
  12. Start Auto Filter by typing Alt+d+f+f.
  13. Move to filter column using the mouse (no keyboard shortcuts?) then select from the drop down list (Custom …).
  14. Select ends width criteria, enter .dll, then press Enter.
  15. Move cursor to required column and select it using Control+Space.
  16. Copy column by typing Control+C.
  17. Start editor.
  18. Paste the text in the clipboard in destination document.

The Excel solution has many more steps than the getclip-putclip solution but Excel leads you through to a solution step-by-step. If you're familiar with GNU tools, then getclip-putclip recipe is faster to use and much more extensible.

2008-05-07. I should have remembered that the basename command would output the name of the file without the leading path string. See later article More Uses of Getclip-PutClip about how to use basename in a pipeline.

Labels: , ,


Tuesday, 19 February 2008

 

Hide Recycle Bin in Windows Desktop

While noodling around Windows' Group Policy Editor, I noticed that you can hide the Recycle Bin in the desktop:

  1. Start Group Policy Editor using gpedit.msc.
  2. Select User Configuration / Administrative Templates / Desktop.
  3. Select Remove Recycle Bin icon from desktop.
  4. Select Enabled radio button.

Note that Windows' Group Policy Editor is generally used to turn off features, so enabling a setting generally means to disable a function.

Labels:


Saturday, 16 February 2008

 

OpenGL for ATI Mobility Radeon in Vista

This is way annoying. I installed an OpenGL game on my Asus notebook and it ran abysmally. When I tried to test the OpenGL interface with glview, that program crashed. The ATI's Catalyst Control Center (CCC) reported that OpenGL Version was Not available.

It turns out that I have to update the driver for my notebook's ATI Mobility Radeon X1700 card and enable OpenGL support. ATI does not support any Mobility Radeon cards but I found an updated driver on the Asus site. Then I used Mobility Modder tool and it enabled OpenGL. Now my system has OpenGL version 6.14.10.7275 and glview runs to completion.

Whew! Thank goodness Mobility Modder worked since I wasn't looking forward to hacking .INF files without knowing anything about configuring video adapters.

Labels: , ,


Wednesday, 13 February 2008

 

Microsoft Excel Remove Empty Lines

If you get an Excel document that has empty rows, you can remove those empty rows by using the sort function (Data / Sort). Of course, you lose the original row order.

Another method is to use the "Go To" (F5) dialog to select all blank cells, then delete them (found in Joseph Rubin's Excel Tips).

Labels: ,


Tuesday, 12 February 2008

 

Copy-Paste Image from CHM to Microsoft Word

If you copy-paste an image from a CHM file to Microsoft Word, you end up with a blank rectangle in your Word document. The workaround is to paste the image to a drawing program (e.g. MSPaint), then copy-paste from the drawing program into Word. Why you need to do this two-step process?

Labels: , ,


Monday, 11 February 2008

 

Microsoft Outlook Rules and Duplicated E-mail

If you use Microsoft Outlook's rules to move incoming messages into folders, you could end up with duplicate e-mail messages if two or more rules can be applied.

Recently, I made new rules to move bug reports for some products into special product folders and I also had a "catch-all" rule to move all remaining bug reports into a general bug report folder. In other words, I had the following rules:

From bugsystem, Subject "product_1", move to "product_1" folder.
From bugsystem, Subject "product_2", move to "product_2" folder.
From bugsystem, move to "general" folder.

I thought once a rule was "fired" for a message, Outlook would process the next message. However when new bug reports arrived, Outlook created two copies of each message, one in the product's folder and one in the general bug report folder. It appears that Outlook processes all rules for a message before proceeding to the next message. Select the stop processing more rules action for each rule to make Outlook stop processing further rules for that message:

From bugsystem, Subject "product_1", move to "product_1" folder and "stop processing more rules".
From bugsystem, Subject "product_2", move to "product_2" folder and "stop processing more rules".
From bugsystem, move to "general" folder.

In Outlook 2003, Rules and Alerts dialog, you can see a hammer and spanner icon for each rule containing the stop processing more rules action.

Labels: ,


Friday, 8 February 2008

 

AutoIt Include Directory

Note to myself to remember to set the local Include directory value for AutoIt when I use another computer. The registry key is HKEY_CURRENT_USER\Software\AutoIt v3\AutoIt.

Labels: ,


Wednesday, 6 February 2008

 

Excel Print Preview Cannot Repeat Row or Column

Quirk in MS-Excel: You can't select rows or columns to repeat if you open the Page Setup dialog in Print Preview (see knowledge base article 912069). The work around is simple: close Print Preview and select the menu item File / Page Setup.

Labels: ,


Wednesday, 28 November 2007

 

Unexpected Windows Scheduled Task Copy-Paste Bug

I never expected to find this bug. In Windows XP, if you try to copy and paste a task in the Scheduled Task folder, you may get this error message: Cannot copy <Task Name>: The source and destination file names are the same. Even the obvious workaround doesn't work: copy a task, rename the original and paste the new task. unlike Windows Explorer, Scheduled Task doesn't seem to give a copied task a name such as Copy of x.

Labels:


Tuesday, 13 November 2007

 

Uninstall Product Desktop Shortcut

During the development and test phase of a project, I have to install and uninstall daily program builds for testing, so I'm pretty interested in reducing the amount of time and effort required to uninstall programs. Here's how my uninstallation process evolved:

In the beginning, use Start / Control Panel / Add or Remove Programs.

Spend less time by starting Windows' Add or Remove Programs dialog using the Run dialog by typing Windows+R appwiz.cpl.

Then you might notice that the Windows XP Add or Remove Programs dialog takes up to 30 seconds to start and there's no quick way to find the desired program. It's annoying that the list of programs doesn't scroll when you hit the PageDown and PageUp keys or when you type the first few letters of a program name. (The Vista equivalent, Programs and Features, doesn't have these limitations.)

Finally, using Windows Installer, msiexec, you could uninstall any program if you have the ProductCode. Just create a desktop shortcut with the following string in the Target field:

C:\WINDOWS\system32\msiexec.exe /uninstall <ProductCode>

P.S. You can find the ProductCode of your program using this script.

Labels: ,


Sunday, 11 November 2007

 

Event 1530, User Profile Service

After having to debug a couple of Windows profile problems recently, I started to keep an eye for Warning or Error events in the Windows Event Viewer. The latest warning was Event 1530, User Profile Service, where there was some conflict between processes writing to the registry as I was logging out and had the following details:

 2 user registry handles leaked from ...:
Process 932 (\Device\HarddiskVolume2\Windows\System32\svchost.exe) has opened key ...
Process 3472 (\Device\HarddiskVolume2\Windows\System32\IFXSPMGT.exe) has opened key ...

Process 3472 is IFXSPMGT.exe (Infineon Security Platform Software) but what was process 932? One solution was to run tasklist and save the list of process numbers in the current session. Here's the command to run:

tasklist /svc /fo table /fi "imagename eq svchost.exe" > C:\Temp\Processes.txt

Very roughly, we are looking for all services started by svchost.exe.

I ran the tasklist command in the previous session and found that process 932 was WinDefend (Windows Defender, Microsoft's anti-spyware program).

14-Nov-2007. For Windows pre-Vista, if you receive Event ID 1517, Microsoft provides User Profile Hive Update (UPHClean.exe) utility to detect and free the registry. There isn't a version of UPHClean.exe for Vista yet.

Labels:


Thursday, 8 November 2007

 

Very Slow FTP Download Fixed

When I download files from our FTP server using my notebook on the company LAN, the download speed was 10 to 20 kbits/sec, which is very slow compared to using a local desktop, where the download speed was closer to 150 kbits/sec. There was no problem downloading files from external Internet sites. The IT guy and I puzzled over this problem off and on; it was annoying but not critical. I tried different FTP clients but there was no difference. Then the IT guy suggested turning off Deterministic Network Enhancer (DNE) (open Local Area Connection Properties and clear the DNE's checkbox). When I restarted my FTP client, the download speed improved to the same level as the desktop.

It turns out that DNE was installed with the VPN software on my notebook. I have to remember to re-enable the DNE when I use the VPN. Still beats me why it only affected FTP downloads from our local server.

14-Nov-2007. It's not DNE. When I reset the network adapter after I start the FTP client, the download speed improved. IT Guy thinks my notebook may require an updated network adapter driver or BIOS.

Updated my Asus BIOS from 214 to 218 and the networking problem seems to be fixed.

15-Nov-2007. It's not the BIOS either. Updated my Realtek RTL8160/8111 network adaptor driver from 5.666.301.2007 to 5.680.1023.2007 and I'll see what happens the next time I restart my notebook.

16-Nov-2007. Success! My notebook download speed went past 130 kbits/sec on the first go.

Labels: ,


Sunday, 28 October 2007

 

GIMP and Inkscape Stylus Tracking Problem

If you use a Wacom Graphire tablet and drawing tools GIMP 2.4 or Inkscape 0.45.1 on Windows Vista, you may find the cursor unresponsive; for instance, it would halt and jump to a new location after a some seconds of use. The problem seems to be caused by the underlying GTK library not processing all the events from the tablet device. Drawing tools that use different libraries, such as Paint.Net don't have this problem.

A work-around is to avoid using devices via the WinTab interface. Just add the following option to the Windows shortcut for the GIMP and Inkscape: --no-wintab.

There's some drawbacks of this work-around:

2008-05-06: Another bug to track is Wacom Bamboo Doesn't Function with GTK apps in Win32.

Labels: ,


Friday, 26 October 2007

 

GIMP 2.4 Released

GIMP 2.4 has been released. For occasional users with Windows Vista, the most noticeable change is that it only takes seconds to load after the first time; in version 2.2.x, it used to take about half a minute. However, support for Wacom tablet is not good; the pointer still freezes after some seconds. Maybe the next version of GTK would improve the situation?

Labels: ,


Friday, 17 August 2007

 

Windows Games Mysteriously Halting

My son found a problem with his computer. Sometimes, the game he was playing would halt after it started. Then he said that if he defragmented the hard disk, the game would start running again. I didn't think too much about it until the problem occurred yesterday evening. When I examined his computer, I realised that it had run out of disk space. The game didn't crash; it was waiting for some spare disk space to write its files. When he defragmented the hard disk, some space was freed up, so the game could continue running. I freed up about a third of the hard disk and there's no problems running games again.

Labels:


Monday, 13 August 2007

 

More Asus Synaptics Touchpad Settings

Set up the following Tap Zones (in the four corners) on my touchpad:

16-Aug-07: Found a better configuration. Changed Bottom Right Action to Middle Click. In Firefox, this opens a link under the pointer in a new tab.

Labels:


Sunday, 5 August 2007

 

ATI Catalyst Control Center Rotate Display

Added some notes on how to use the ATI Catalyst Control Center to turn computer display 90° clockwise and anti-clockwise. Sort-of useful for reading on-line documents, such as webcomics, in portrait format.

9-Aug-07: This feature isn't available on another Asus laptop with Windows XP. Maybe it's just a Vista feature?

Labels:


Wednesday, 18 July 2007

 

Remove Word Drawing Canvas

When making a Microsoft Word Picture in Microsoft Word 2003, the drawing editor first adds a drawing canvas. Apparently, the canvas allows the user to keep shapes together when printing, so that the picture isn't split between two pages. While it might be useful for shapes inserted into a document, there's isn't much point having a canvas in a Word Picture object, because that's displayed in one page. To stop Word from automatically adding a drawing canvas, select Tools / Options / General and uncheck Automatically create drawing canvas when inserting Autoshapes.

Labels: ,


Monday, 16 July 2007

 

Outlook Change Email Address Type

Because I work on-site, sometimes I add a Outlook contact from the client's Exchange server. If I do that, I can only send e-mail to that person using Exchange, even though I enter what appears to be an SMTP address in that contact's e-mail field. When I try to send a message to that person using an SMTP server, Outlook produces this cryptic error:

Task 'xxx.com - Sending' reported error (0x80070057) : 'Could not complete the operation. One or more parameter values are not valid.'

When I look at the contact's e-mail fields (select the contact's All Fields tab, then choose E-mail fields in the Select from: field), I see that Email Address Type is EX instead of SMTP. I think this means that Outlook would use some Exchange-related protocol to send messages to this contact.

The hack to change Email Address Type is …

  1. Select the contact's details.
  2. In the General tab, replace the existing the e-mail address with a string starting with smtp:. For example, replace a.b@mail.x.com with smtp:a.b@mail.x.com. Note: you have to type in the new dummy address; if you use a suggestion from Outlook, the address type does not change.
  3. Select the Properties context menu item of the dummy e-mail address. Outlook should display the E-mail Properties dialog. Note that the E-mail type: field now has a value of SMTP.
  4. In this dialog, remove the smtp: prefix from the e-mail address.
  5. Press the OK button and the dialog should close.
  6. Initially, the Contact's e-mail address does not seem to have changed. If you click on the Display As: field, Outlook corrects the e-mail address.
  7. Delete the string in the Display As: field and press Enter. Outlook should refresh the Display As: field.
  8. Save the updated contact.

See also this description.

If you want to find out the address type of all your Contacts, just add the E-mail Address Type column to your list of contacts view.

Labels: ,


Saturday, 14 July 2007

 

Vista Tablet Input Panel Revisited

Found some better ways to use Vista's Tablet Input Panel (TIP):

Labels: ,