Thursday, July 18, 2013

One minute Windows 7 boot delay

I was recently upgrading my primary boot disk in my desktop PC (upgrading from an OCZ Vertex2 to a Samsung 840 Pro SSD) and after the usual exercise, I found an odd problem.

During bootup, the system would hang on the "Starting Windows" screen (the throbbing windows logo) and pause for about one minute. After this delay elapsed, my KB would then initialize normally, and the boot splash screen would disappear and normal bootup would take place.

After a lot of trouble I discovered the following were not the source of the problem:
  • Rolling back recent Windows Updates
  • My new SSD disk (vs. the old one)
  • SSD settings in WIndows
  • SSD drive firmware
  • AHCI settings in BIOS/Windows
  • MS AHCI drivers vs. AMD AHCI drivers
  • BIOS disk boot sequence
  • Removal of my SATA DVD-RW drive
  • Hibernation and Pagefile settings and systems

I list these here because they include most of the usual suspects to investigate when trying to solve boot delays.

In the end, the solution was simple. I had to unplug my external Thermaltake BlackX eSATA disk dock.

I had plugged it in as part of my boot disk cloning (I use TrueImage) and hadn't removed it. When it was connected but with no disk in it, it caused the system boot hang.

I don't know for sure, but I'm guessing it was causing some 60-second AHCI disk command/discovery to timeout during boot.

Thursday, July 4, 2013

Sventon 2.5.1 with SVN server 1.7+ to view/download files

The Sventon tool is a useful web interface to allow browser access to Subversion/SVN data repositories.

It is particularly useful when your repositories are not hosted with Apache, and you want to give some level of read/view access to data in your repository without requiring the installation of a tool like TortoiseSVN.

While useful, Sventon v2.5.1 hasn't changed in a few years, and unfortunately is not fully compatible with Subversion servers running engine 1.7 or later. In particular, while most aspects work, viewing the actual contents of a file in the repository causes an error "Cannot get contents of file".

The problem is that Sventon includes a copy of the SVNKit library 1.3.4, and this version unfortunately has a bug uin it, which means certain types of requests to the SVN server no longer work (for security reasons, server 1.7 adds additional checks and verifications and rejects the slightly erroneous requests from Sventon/SVNKit 1.3.4.)

Luckily, the solution is quite simple. While Sventon hasn't been updated, it's relatively simple to manually upgrade SVNKit from 1.3.4 to verison 1.3.8, which corrects the bug and works fully with SVN server 1.7 and 1.8.

So to solve the problem:

  1. Back up your working Sventon deployment, configuration, and cache, just so you can revert if needed.
  2. Download SVNKit 1.3.8 (I avoided and have not tested SVNKit 1.7.9)
  3. Shut down your application server (Tomcat6, etc) or at least stop the /svn application.
  4. Copy all files from the 1.3.8 /lib directory, into the lib directory for your Sventon deployment (e.g. webapps/svn/WEB-INF/lib)
  5. Remove all duplicate prior versions of JAR files from that Sventon deployment that were replaced with newer equivalents from SVNKit 1.3.8 vs. 1.3.4:
    • svnkit-1.3.4.jar (replaced by 1.3.8)

    • antlr-runtime-3.1.3.jar (replaced by 3.4)
    • jna-3.2.2.jar (replaced with 3.4.0)
    • sequence-library-1.0.0.jar (replaced by 1.0.2)
    • sqljet-1.0.3.jar (replaced by 1.1.2)
    • trilead-ssh2-build213-svnkit-1.3-patch.jar (replaced with 1.0.0)
  1. Create an equivalent svn.war that includes the same changes as above.
  2. Restart Tomcat/Sventon and verify functionality.

Using this approach, you should be able to fully use Sventon 2.5.1 on newer Subversion servers based on SVN 1.7 and 1.8!

Important Note: it may be possible to just upgrade WEB-INF/lib/svnkit-1.3.4.jar to svnkit-1.3.8.jar, but I haven't tested that. I chose to update all the libraries that SVNKit ships with, and have not seen any problems in doing so.



Friday, November 16, 2012

A shortcut to launch a recent download

When download files in a browser, I prefer to save all the files to a specific location instead of allowing the browser to "open" the file. This means that to invoke the download I have to go to an Explorer window or command prompt and manually select/run the file.

So I chose to create a shortcut on my Quick Launch (yes I still use it in Windows 7) to automatically launch my "most recent download".

This isn't a particularly complex task or hard to figure out, but I thought I'd document it here anyway. There are probably better ways to do it too, but I'm most familiar with Windows Batch approaches to automation.

Step 1: Write a Batch File

I created a NEW_DOWNLOAD.BAT file and placed it on my system somewhere. The contents are:

@echo off

call :latest e:\download\*.exe ^
             e:\download\*.rar ^
             e:\download\*.zip ^
             e:\download\*.pdf

if "%LATEST%"=="" goto :eof
echo E:\DOWNLOAD\%LATEST%

if "%1"=="" "E:\DOWNLOAD\%LATEST%"
if not "%1"=="" copy /y "E:\DOWNLOAD\%LATEST%" "%1"
goto :eof


:latest
FOR /F "delims=" %%I IN ('DIR %* /B /O:-D') DO (
   SET "LATEST=%%I"& goto :eof
)
goto :eof



Basically what this does, is search my E:\DOWNLOAD folder for all .EXE, .ZIP and .RAR files, and launches the most recent one. You could add additional file types here if you wanted to.

Step 2: Add a Shortcut

I added a shortcut to NEW_DOWNLOAD.BAT and placed it on my Quick Launch bar. I configured it to launch Minimized, and gave it a custom icon from SHELL32.DLL to distinguish it. I also added a keyboard hotkey for the shortcut (CTRL-SHIFT-L.)


Step 3: Set it and Forget it

Now, when I download something, I just click on the Quick Launch shortcut or press my keyboard hotkey, and automatically my most recent download starts running.


For reference, I use a similar script now to "Display the most recent PDF file" in another folder, in combination with CreatePDF as my default print driver, to print/save and verify document output.

Tuesday, September 4, 2012

Linux "Welcome to GRUB" hang on IBM x3200 Server

I recently had to migrate a working linux/debian server image over to a "new" machine, an IBM x-Series M3 x3200 (machine type m/t 4362-PAT.)

Normally server installations of Linux are decent about body transplants across the same architectures, so I was surprised to find that the disk wouldn't boot on the new system.

The symptom was a very slow display of "GRUB" then "GRUB loading" then finally a hang on the "Welcome to GRUB" screen.

The first thing I did was boot on the Debian netinst CD for my install and choose the rescue option, and re-install GRUB onto the boot partition, but this did not fix the problem.

After further research, I cam across this post which suggested the cure to my problem: I needed to disable the graphical mode for GRUB and only use the traditional console mode boot. On my system, this was done by editing the file /etc/default/grub, and enabling the following setting:

# Uncomment to disable graphical terminal (grub-pc only)
GRUB_TERMINAL=console                               

After making this change, the system boots like a champ!

Monday, August 13, 2012

A canonical list of Windows service names for antivirus and antimalware tools

I had a need to modify some code to check for the presence of a range of anti-virus and anti-malware tools running as a service on a Windows system.

As a background, my purpose was to find different AV services and, if multiple AV tools are starting up and running, to delay an operation until the services had finished initialising (ie, in the RUNNING state.)

As part of this exercise, I could not find a list of Windows services names for the common anti-virus tools available [let me know if you know where one is!] So while the information is not too hard to dig up for each tool, I decided to document this list here for future reference.

  • symantec antivirus:: Symantec Endpoint Protection
  • mcshield:: McAfee Security
  • windefend:: Windows Defender
  • msmpsvc:: Microsoft Security Essentials
  • msmpeng:: Microsoft Security Essentials
  • savservice:: Sophos Antivirus
  • aveservice:: Avast!
  • avast! antivirus:: Avast!
  • immunetprotect:: Immunet Protect
  • fsma:: F-Secure
  • antivirservice:: AntiVir
  • avguard:: Avira
  • fpavserver:: F-Protect
  • pshost:: Panda Security
  • pavsrv:: Panda AntiVirus
  • bdss:: BitDefender
  • abmainsv:: ArcaBit/ArcaVir
  • ikarus-guardx:: IKARUS
  • ekrn:: ESET Smart Security
  • avkproxy:: G Data Antivirus
  • klblmain:: Kaspersky Lab Antivirus
  • vbservprof:: Symantec VirusBlast
  • clamav:: ClamAV
New additions:
  • SBAMSvc:: Vipre / GFI managed AV
  • navapsvc:: Norton
  • AVP:: Kaspersky

Note that this is a reference to the Windows "Service name" value for the tool, as opposed to the Display name or Executable/Process name.

Many of these are based on web searches and information found online and have not been verified personally. Certainly, this list is by no means complete or guaranteed accurate!

If I receive corrections or additions to this list or need to extend it, I will edit this post!


Thursday, July 12, 2012

Windows does not use my VPN connection DNS!

I have  problem on one of my systems where I frequently use my VPN connection to link to the office. The problem is that the DNS resolution always seemed to go through the main WAN connection system, and never defer to the VPN connection DNS servers.

It may be related to newer WAN DNS that return results and do web redirection for "unknown" connections, instead of returning no match.

After some basic searching, I cam across this post that had a solution:

Force Windows to Use a VPN's DNS Server

Going through these instructions solved my problem. I am running Windows 7 x64 and the solution took effect immediately upon restarting my VPN client.

For reference, this is what I did:

  1. Open Regedit.
  2. Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Linkage
  3. In the right pane, double-click Bind
  4. In the value text box, select the "\Device\NdisWanIp" item, press CTRL+X, click the top of the list of devices, and then press CTRL+V.
  5. Click OK, and then quit Registry Editor.
  6. Restart your VPN connection.

Friday, March 16, 2012

New iexplore.exe processes exit immediately and the page loads in a different process!

As part of some process management software that handles multiple web pages and web-based applications, I recently encountered some problems with Internet Explorer.

The symptoms of my problem:

  1. Attempt to launch a new page/web-app in a separate iexplore.exe process for Internet Explorer
  2. The process launches successfully but very quickly exits with rc=0.
  3. A new iexplore.exe is created that is not a child of the process I created, but of another existing Internet Explorer session.
  4. The requested content appears successfully under that other process
  5. My process/handle management logic is confused since it thinks something is broken!

After a brief amount of research, it turns out this is due to a change in Internet Explorer 8 (IE8) regarding how UI components, frames, tabs, and plug-ins are isolated into different processes. This is called "loosely-coupled Internet Explorer" or LCIE, and this is documented in two MSDN IE blog posts from Microsoft:

  • http://blogs.msdn.com/b/ie/archive/2008/03/11/ie8-and-loosely-coupled-ie-lcie.aspx
  • http://blogs.msdn.com/b/askie/archive/2009/03/20/how-to-i-determine-which-ie-tabs-go-to-which-iexplore-exe-process-when-using-internet-explorer-8.aspx

While these changes are very useful from an end user point of view, for security and robustness reasons, they aren't what I need. Thankfully, Microsoft included a way of avoiding some aspects of this change in IE8 to mimic the process behaviour of previous versions:


The simple solution:

When manually launching an iexplore.exe process, add the following "-nomerge" command line option as part of the request.

"iexplore.exe -k -nomerge C:\path\app\index.html"

Once I modified my process manager to use this option, my existing logic that worked fine under IE6 and IE7 also works with IE8!

Wednesday, October 19, 2011

Loose lens head on Tamron 17-50mm F/2.8


On a recent trip to Utah I brought my trusty combination of a Canon 60D and my favourite all-purpose lens, my Tamron 17-50mm F2.8 (non-VC.)

Part of my itinerary involved a backcountry ATV tour, and I had the camera gear in a padded case strapped to the Honda's rear cargo rack. By the end of the 4 hour tour, I noticed that the lens "head" on the Tamron was very loose and wobbly -- this is the part that holds the lens cap and filters.


The optics of the lens were still fine, the wobbly was only in the plastic end piece. After searching for a solution, it turns out this is a relatively common problem with this and other Tamron lenses, and the solution is quite simple.

Using a small jeweler's screwdriver, behing very careful to avoid damage to the optics, the following DIY fix is very quick and easy -- it took me under a minute.

Firefox Sluggish with newer AMD HD 4290 Video Driver

I recently upgraded my system video driver to address some video playback issues. In my case, I had been running the latest AMD 890X Chipset drivers with HD4290 GPU graphics support.

I am running Firefox 6 and FireFox 7. Prior to the video driver upgrade, Firefox ran smoothly and quickly. After upgrading to the latest HD 4290 drivers provided by Windows Update, I noticed Firefox seemed sluggish. My system is otherwise very fast (AMD 1090T X6 with 12GB of RAM and SSD) so the speed degredation seemed very related to the video driver update.

It wasn't "slow" but things like switching tabs suddenly had a very short, but noticeable, delay. Another symptom was that sometimes, when launched, Firefox would display a grey translucent screen with diagonal bars for a brief moment.

After some Google research, it became apparent that ability in recent versions of Firefox to detect and use "GPU acceleration" to speed up browsing, did not always improve things. So, in effect, disabling GPU acceleration in Forefox returned my browser to normal snappy speeds. The setting to change is:
  • Open Firefox Tools::Options
  • Go to Advanced
  • Select the "General" tab
  • Uncheck the option "Use hardware acceleration when available"
I tried various versions of the ATI Catalyst drivers for the HD4200 series GPU, but all seem to have the same slow Firefox behaviour when running with GPU hardware acceleration (I tried Catalyst 11.6, 11.7 and 11.9.)

EDIT 11apr2012: still a problem with Firefox 11 the latest Catalyst 12.3 drivers, grrr...

Many sights indicate this option needs to be unselected for "older" graphics processors, but it's odd that it affects the HD4290, which is a relatively recent onboard GPU solution that is certainly not out of date.

Oh well -- since I don't need advanced HTML5 support in Firefox yet, no problems leaving this hardware acceleration option off for now.

Friday, June 24, 2011

Image colours too bright/saturated in Google Chrome!

My regular browser is Firefox, but I was recently look at my online photo gallery in Google Chrome to see if some of the slideshow effects were working properly.

One thing I noticed almost immediately was that a lot of my pictures had very garrish colours, much more oversaturated than the same pictures/URLs appears in Firefox or IE (on the same monitor.)

Given that I have a Dell IPS monitor, the gamut and saturation are inherently quite a bit higher and Windows and applications need to be colorspace aware to properly display colours. So some searching led me to this page: http://www.binaryturf.com/enable-color-management-google-chrome/

It looks like even now, Google Chrome still does not enable color/monitor profile support by default! Yikes... Adding the setting described above corrects the problem on my monitor. ie, the solution is:

  1. Edit the Google CHrome startup shortcut
  2. Add the startup parameter " --enable-monitor-profile" to the end of the command line.

Friday, December 24, 2010

No sound from XM Radio Online and Gadget, or WMP Streaming

NOTE: As of Feb 05 2011, SiriusXM have updated their online streaming infrastructure, and the traditional tools such as the Build-a-Gadget XM Radion Online widget no longer work.

If you're having problems streaming XM in general, it is likely that your XM-specific 3rd party tool is now deprecated and can no longer be used.

After a recent hardware upgrade on my system, I noticed that my XM Radio Sidebar Gadget stopped playing sounds, despite all other sounds apparently working on the system. After further testing, the actual XM Radio Online page also did not work. In both cases, the player component would just revert to "Ready" without any error message.

In the end (and for other reasons), I ended up completely re-installing my system, but the same problem reappeared in a few days. My OS is WIndows 7 x64 Ultimate, but internet research suggests this problem happens on a range of Vista and 7 systems -- or anything running WIndows Media Player 11.0 or 12.0.

Some initial research suggested that it was a problem with the Macromedia Flash player, but wiping and reinstalling this didn't work. Nor did the usual wipe and reinstall of sound card drivers. In my case, the problem happened with numerous sound cards (Creative X-Fi as well as onboard.) Eventually, my research let me to this thread, which proved key to solving the problem:

It turns out that the Windows Media Player settings for streaming somehow become corrupt/reset. All non-streaming play and sound still works. So the solution is to erase the WMP settings and make it recreate .

  1. Locate the directory on your system drive that contains the file WMSDKNS.XML.
  2. In my case, on WIndows 7 x64, it is C:\Users\username\AppData\Local\Microsoft\Windows Media\12.0
  3. Delete or rename that directory, for example to "...\Windows Media.backup" If the system says it is locked, make sure you remove all streaming gadgets from the sidebar, reboot the system, and don't start media playing after startup.
  4. Once the directory is deleted, re-install the XM Radio Sidebar Gadget. Start playing a channel. If you have solved the problem, you should get sound.
  5. You can check that WMP recreated the directory and created a new WMSDKNS.XML file.
In my case, my "corrupt" file was 819 bytes. The new default one recreated by Windows and WMP was 10,191 bytes -- quite a difference!

Wednesday, October 27, 2010

Smoothwall 3.0 Express web GUI not working after update

I recently applied a set of updates to a local Smoothwall Express 3.0 box I have here. Everything is still working fine, but the web GUI stopped working completely. Both Firefox and IE seem caught in a loop trying to load the page, and it effects both http and https interfaces. After much research (it would've been quicker to just reinstalled Smoothwall from scratch!) it turns out there is a problem in update7 with the SSL handling.

To resolve the problem, log into your smoothwall SSH console, and delete the following files then reboot the system. After this, the web GUI should work:
  • /var/log/httpd/ssl_scache.dir
  • /var/log/httpd/ssl_scache.pag

Wednesday, August 25, 2010

Windows Server 2003 looses default gateway with multiple NICs

I have a server that is connected to two network interfaces. Both interfaces are assigned addresses and gateways via DHCP. One is a fast gigE connection to a private test/NAS LAN, and the other is a connection to the intranet and to the world.

The connection to the world is through a crappy router/firewall that has difficulty handling full bandwidth transfers without quivering to a temporary state of stasis. Over the last few months, and in particular over the last week, I had noticed that the server machine was losing its default gateway connection to the world. So all incoming connections were being routed back through the lower priority/metric gateway on the test LAN -- and going to a black hole. Odd. Users annoyed, too.

It turns out Windows Server 2003 has a feature called "dead gateway detection" -- if the highest metric/priority gateway requires more than X retries on a send, Windows flags it as bad, drops it from the routing table, and moves on to the next default gateway. Here are some Microsoft links on the setting:

Interesting that Windows essentially supports "fail-over" to secondary gateways, but does not appear to "fail-back" to the original gateways later once their connection is restored. So Windows has no way to recover the lost connections once the condition has triggered the fail-over. Since MS themselves recommend disabling this feature as part of "hardening" the TCP/IP stack (to prevent a DoS vector), I went ahead and did this. Tweak the dollowing registry settings:
  1. HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameter\
  2. Add/set the DWORD key value "EnableDeadGWDetect" to 0
  3. Reboot the system to apply the change.
Another alternative is simple to only have one default gateway on your TCP/IP stack -- which is the approach many network gurus advise. With only one gateway to work with, "Dead gateway detection" does not activate. I did this as well, and set up numerous persistent direct routes for those connections that needed to go through the test/NAS LAN as opposed to the rest of the world.

So far with these changes, things are going good.

Tuesday, July 27, 2010

rinetd fills your syslog with errors

I recently made some changes to the rinetd configuration on the linux development server here. Everything seemed to work fine, but a few days later I noticed the follow wharrgarbl in my syslog:

Jul 27 14:28:11 easserv rinetd[14712]: accept(0): Socket operation on non-socket
Jul 27 14:28:42 easserv last message repeated 546042 times
Jul 27 14:29:43 easserv last message repeated 1077719 times
Jul 27 14:30:21 easserv last message repeated 680478 times

After searching around, it turns out I had made a typo in one of my rules. Instead of using the currentl 10.10.10.254 address, I had this new entry:

0.0.0.0 38254 10.10.10.255 80

So having an invalid IP address in those rules, causes rinetd to have a fit. Changing the 255 to a 254 and restarting rinetd solved my problem.

Sunday, July 18, 2010

Adobe Lightroom 3 hangs on Import with JungleDisk

I've been playing around with the new Adobe Lightroom 3 for Windows, now that it's released. So far, it looks pretty good!

One thing I noticed right away was that its Import functionality (which is completely redesigned for LR3) appeared to hang indefinitely on my system. After quite a bit of research, I found this Adobe Forums thread that helped me solve the problem: JungleDisk drive mapping presents itself as a Removable Drive, which LR3 automatically attempts to scan.

Because the mounted JungleDisk drive connects to the Amazon S3 storage service, it is a slower WAN connection and Lightroom will probably sit there for minutes or hours trying to scan the entire drive. The solution is to configure JungleDisk to present its mounted drive as a Network Share instead:

  • Go into Jungle Disk Desktop Monitor
  • Click on Configure
  • Select Network Drive::Local Drive Mapping
  • Make sure "Show Advanced Options" is checked at the lower-left
  • Change the "Drive Type for all Online Disks" option to "Network share"
Once you do that, the Lightroom Import dialog should be much smoother.

Sunday, December 6, 2009

D-Link DIR-655 and Logitech MX Mouse interference

I haev been trying to troubleshoot some performance issues between my Lenovo X200s with Intel 5300 802.11N network, and my D-Link DIR-655 routers. After trying things including updating firms, drivers, and the like, I also noticed that the performance of my desktop mouse was very choppy whenever I was doing wireless transfers.

My desktop mouse is a wireless Logitech MX Revolution, which is of course a 2.4GHz device just like 802.11. After some research, I found that the MX mouse receiver can interfere with a wireless router if it's "too close". In my case they were about 5" apart, since my USB hub is very close to the wireless router.

I moved the mouse received directly to the PC, about 20" away from the router, and all "mouse chopiness" has disappeared. I still don't know if it was ultimately the cause of my problems, but for better performance, make sure you physically separate your wireless router and wireless mouse/kb dongles!

Friday, December 4, 2009

TortoiseSVN overlay icons broken after JungleDisk 3 installed

I run TortoiseSVN as a source control tool on my desktop. As is usually, files and directories under source control have various icon overlays to indicate their control status.

After installing JungleDisk 3.0, I noticed that these TortoiseSVN overlay icons no longer worked. Following a bit of research it turns out that something else was interfering with the overlay icon settings in Windows. In this day and age, Windows apparently still has some hardcoded internal limits on this sort of thing. Geez.

In Windows, you can have at most 11 defined overlay icons. Due to the nature of source control, tools like Tortoise legitimately use up a lot of these slots. However, JungleDisk as of version 3.0 includes a feature called "Synch" which is some sort file backup scheme.

Unfortunately, JungleDisk forces installation of its own overlay icons for the Synch feature. Not only that, it rudely injects them with reference names intending to keep them at the top of the Windows list. So if that install makes the total overlay count exceed 11, the JungleDIsk install breaks the behaviour of other tools already running fine on your system -- without even asking you.

To fix this, use the registry editor to open:

 HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion
\explorer\ShellIconOverlayIdentifiers
And remove the keys installed by JungleDisk; they are the ones that start with "1Sync", "2Sync" and "3Sync". After removing them, you will need to reboot for the change to take effect.

I have sent a note to the JungleDisk people asking them to fix their installer.

Wednesday, August 5, 2009

Automatically run a command after waking up from Sleep/Standby

I came across a situation recently where I needed to have my Windows system run a command automatically every time the system woke up from Sleep/Standby/Hibernation: a custom monitor colour calibration profile was lost and needed to be explicitly restored every time the system woke up (see previous post.)

In my quick research, by no means exhaustive, I found three ways of doing this under Windows:

  1. If you're (un)lucky enough to run Vista, you can set up a Task Scheduler job that reacts to a System Event
  2. Alternatively, you can install a Windows utility whose exact purpose in life is to run stuff whenever you suspend or resume the system.
  3. You can write a simple tool, service, or Windows script to respond to and process the Windows power events, and do whatever you need to to.
In either case, the idea is that you will run a tool or script or batch file that you create and control, and you get the system to run it.

In my case, the machine is running Vista so I first explored option 1. For my needs, it works very well. Under Vista only (as far as I can tell this is not possible under earlier versions of Windows) here are the steps to create a Task Scheduler entry to run when the system resumes:
  • Run "TASKSCHD.MSC" to bring up the Task Scheduler
  • From the Task Scheduler Library actions choose "Create Task"
  • Fill in the General information as needed
  • Under Triggers, choose New and Begin the task "On an event"
  • Set basic settings Log:System, Source:Power-Troubleshooter and Event ID:1
  • Click OK and go to Actions
  • Set Action:Start a program, and enter the location of your script/tool
  • Review the Conditions and Settings tabs and adjust as needed

Once this is done, save the task and test it by choosing "Run" with the item selected. Once this is working, test it by suspending then resuming your system, it should work!

Another alternative for all versions of Windows is Hibernate Trigger. It is a simple tool that is easy to install and configure, and doesn't require any additional information here really. Basically:

  • Create your script, e.g. C:\WAKEUP.BAT
  • Install and run Hibernate Trigger
  • Configure it to run C:\WAKEUP.BAT on Resume
The third option is if you want to roll your own tool (similar to Hibernate Trigger probably) that responds to the Windows power events directly and does what you want. I have not investigated this option since the first two alternatives meet my needs, but there are two main options you can use:


So those are a few solutions to meet the need of running tasks after system sleep. Most people don't need to do thise, but those that do it's a good trick to know.

Make a Spyder2express color profile "stick" after standby/sleep

I recently bought a new Thinkpad X200s and it's quite nice. One symptom that affects many notebooks, perhaps exacerbated by newer LED backlights now in frequent use, is that LCD displays have a very "cold" or "blue" tinge. Apparently this makes them look "better" in store compared to older, yellowing screens; anyway...

As any photo or design pro (which I am neither) will tell, doing any photo processing on a screen that has incorrect colors leads to bad results. For very "cool" screens, this results in garish and darkened flesh tones, and a some colour over-saturation. Since I will be on the road with this laptop and taking pictures, I decided to get a basic hardware screen colour calibrator, the Sypder2express from Datacolor which is under $100.

Now for my basic needs, this simple unit (pro units can cost hundreds or thousands) worked as advertised and as designed, and the software is kept up to date (Vista x64 support was a download away.) The problem that became apparent immediately was that the new colour settings in Windows were LOST every time the system resumed from sleep/standby.

According to Datacolor's support response (prompt, if a bit flippant) was that this is a Windows problem, not a product problem, and that they had a software workaround in, you guessed it, only in their more expensive products.

Not surprisingly, many tools out there are available that can help without a costly upgrade. The one I ended up using was xcalib, a command-line calibration tool for Windows and X. To solve my problem, I configured Windows to invoke on Resume, a script that runs the following commands (after copying xcalib.exe from the download link into my PATH):

  1. xcalib -clear
  2. xcalib
The first command clears any existing color settings in your video card. The second one (re)applies your default color calibration settings that the Spyder2express tool generated and installed into Windows.

Alternatively, you can configure the second command to run "xcalib " to apply a specific color profile. For example, to explicitly apply the Spyuder2express color setting installed into Windows, you would run:

  1. xcalib -clear
  2. xcalib c:\windows\system32\spool\driver\color\Spyder2express.icm
I found that for some reason, xcalib would on occasion not apply the color file properly. Adding the "-clear" command first fixed this; it may not be necessary on all systems.

To figure out how to configure Windows to run a script on Resume (after Sleep/Standby/Hibernate) see my next blog post. In my case, I created a "WAKEUP.BAT" system batch script and added the xcalib commands to it.

Monday, June 22, 2009

Applets don't initialize until browser window displayed

Here's a problem that first solved many years ago, forgot about, and had to solve in a new bit bit of code recently. My poor documentation originally and deficient memory since then cause me to waste an hour re-fixing the problem -- at least I knew I had solved it before!

I have a utility that uses embedded browser controls that contain java applets. These browsers are launched in the background and operate without user interaction until activated by a controlling GUI interface.

Many years ago Microsoft released an IE update that, as part of their settlement with Eolas meant that embedded ActiveX controls were more of a pain to work with because of a "click to activate" policy. While this has since been resolved in a later update, an odd behaviour traced back to that initial ActiveX update remains in place causing a headache:

When I launch a process that embeds a web page containing an applet, the applet does not initialize (even though the Java Console is there) until the tool containing the browser control and embedded page is somehow displayed on the desktop.

The scenario is as simple as a Win32 app started with this general approach:

hwnd = CreateWindowEx(...);
ShowWindow(hwnd,SW_HIDE);
UpdateWindow(hwnd);

Until hwnd is somehow activated on the screen via some other method, the Java plugin for the applet included on the embedded page starts up but the applet does NOT initialize. As soon as the hwnd is displayed, the JRE initializes the applet.

To avoid this problem, it's as simple as adding in an initial hwnd activation:

hwnd = CreateWindowEx(...);

SetWindowPos(hwnd,HWND_BOTTOM,0,0,
GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN),SWP_NOACTIVATE);
ShowWindow(hwnd,SW_HIDE);

UpdateWindow(hwnd);

With this change, the hidden applet merrily initializes and does its normal startup work.