Archive for the ‘Windows’ Category

How to sleep in a Windows .bat script

Friday, December 18th, 2015

There is no sleep command for the Microsoft command line. Here is one way to add a fixed delay to a batch file script:

Use the ping command to ping an invalid address and set the timeout for the number of milliseconds you want to delay. So for example, the following command would delay for 5 seconds before proceeding:

     @ping -n 1 -w 5000 > nul

Fix Broken Windows Boot After Installing Linux (grub)

Monday, October 8th, 2012

When you install Linux or another OS alongside Windows in a dual-boot configuration, the installation often sets up a boot loader like grub to manage the booting alternatives. This can sometimes break the Windows boot loader, which can cause problems in certain situations.

One situation is where you have a Windows hard drive and a Linux hard drive. It works fine as long as both drives are installed, but say you remove the Linux hard drive: you would expect the Windows drive to boot up straight into Windows. But instead you might get a message like “BOOTMGR is missing”.

Another situation that I ran into was that I could not upgrade Windows 7 to SP1 in my dual-boot configuration.  Reasons why are discussed here.  I had to revert the boot loader back to booting directly into Windows before the Windows 7 SP1 update would stick.

There are also a few other situations that might cause your Windows boot loader to get corrupted, and you probably don’t want to resort to restoring your entire drive from a backup image or re-installing Windows from the ground up.  So here’s one relatively easy way to fix your boot.

Repairing the Windows boot loader

Here is one way to repair the Windows boot:  Find a Windows Full or Upgrade install disc. Boot from it. When it comes up, select your language, then at the next screen, select the Repair Windows option at the bottom of the screen. Select the Startup Repair. Indicate which version of Windows you would like to repair, if it finds more than one installation on your hard drive. It will do some checking, and should find that your BootMgr is in need of repair. Tell it to repair the problem. After that it should boot directly into Windows again.

This works with a Windows 7 Upgrade disc.  I’m not sure about Windows XP.

Setting up Cygwin

Wednesday, September 19th, 2012

CygwinThis is my procedure for installing Cygwin on a Windows desktop. There are many ways to configure the Cygwin environment. This seems to work for me:

  1. Go to
  2. Download the Cygwin installer/updater to your desktop
    1. Choose setup_x86.exe (32-bit installation), or
    2. Choose setup_x86-64.exe (64-bit installation)
  3. Run it

Use the following settings to answer the setup questions:

Root dir:  c:\cygwin  (for 32-bit; or c:\cygwin64 for the 64-bit install)
Install for:  All users
Default file type:  DOS
Package dir:  c:\cygwin_install (recommended; can be deleted later)

Be sure to install the following packages:

Section  Package
------- -------
Net     inetutils
Net     ncftp
Net     openssh
Net     ping
Python  python
Python  python-imaging
Python  python-tkinter
Shells  chere
Shells  mintty
Shells  tcsh
Shells  xterm (for resize)
Utils   ncurses (for tset)
Web     wget

Set the HOME environment variable in Windows (Computer->Properties->Advanced->Environment Variables) (put your username instead of username):

Win XP:
HOME  c:\Documents and Settings\username
Win Vista/7/8:
HOME  c:\Users\username

Optional environment variables:

$OSG_HOME (OpenSceneGraph)

Set the PATH environment variable. Cygwin will inherit the Windows PATH, but you need to add the directories containing the Cygwin executables. This is a very minimal .cshrc file. You will probably want to add a more sophisticated one. I have a small set of “dot” files that I copy into a user’s HOME directory when setting up Cygwin. To create the minimal .cshrc file, type the following lines at a shell prompt, ending with the <Ctrl-D> (Cygwin EOF) character:

/usr/bin/cat > $HOME/.cshrc
set path=(/usr/local/bin /usr/bin /bin $path)
setenv CYGWIN nodosfilewarning

Run the following commands (put your username instead of username):

Win XP:
/usr/bin/mkdir /home
cd /home
/usr/bin/ln -s /cygdrive/c/Documents\ and\ Settings/username/My\ Documents username
Win Vista/7:
/usr/bin/mkdir /home
cd /home
/usr/bin/ln -s /cygdrive/c/Users/username username


mintty shortcut:

C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico /bin/tcsh

Create ~/.Xdefaults containing the following:

rxvt.scrollBar_right: True
rxvt.visualBell: True
rxvt.cursorColor: red
rxvt.saveLines: 5000
rxvt.geometry: 80x40
rxvt.font: courier
rxvt.foreground: black
rxvt.background: white
xterm.scrollBar_right: True
xterm.visualBell: True
xterm.cursorColor: red
xterm.saveLines: 5000
xterm.geometry: 80x40
xterm.font: Consolas
xterm.foreground: black
xterm.background: white

Put mintty in the Windows Explorer folder right-mouse menu:

Run the following command to create a Windows Explorer context menu entry:

/usr/bin/chere -if -t mintty -s tcsh -e "Cygwin Terminal Here" -o "-i /Cygwin-Terminal.ico"

If you get an error like this:

Error (5): Access is denied.
/usr/bin/chere Error: Hive not writable
/usr/bin/chere: Aborting.

it is a UAC (permissions) problem.  Launch the shell as Administrator and try it again.

Modify /etc/csh.login as follows, to let the shell run by chere start in the proper directory:
Replace the last line:



if ( ! ${?CHERE_INVOKING} ) then

AppleSyncNotifier.exe – Entry Point Not Found

Monday, April 30th, 2012

This error occurs on Windows (Win7 64-bit in my case) after an iTunes update.  I have had to fix this two or three times now.  I do the install, but on the next reboot I get a popup titled AppleSyncNotifier.exe – Entry Point Not Found.  The message in the popup is:

The procedure entry point sqlite3_clear_bindings
could not be located in the dynamic link
library SQLite3.dll.

To fix it, copy SQLite3.dll from

C:\Program Files\Common Files\Apple\Apple Application Support


C:\Program Files\Common Files\Apple\Mobile Device Support

It looks like other people might get slightly different errors, so you may need to copy other DLLs also.

My guess as to what is happening here is that putting a copy of the DLLs with the Apple software causes the Apple software to use that copy.  Otherwise it gets whichever  version of the DLL comes up first in the system search path.  Since many tools use some of these support libraries, it’s a bit of a crap shoot.

The last time I had to fix this problem, The How-To Geek blog article here helped me remember what to do.

Caffiene for Toshiba Drives

Wednesday, April 18th, 2012

I'm sleepy.  Where's my cover?We have some Toshiba USB drives whose power-saving feature puts them to sleep at inconvenient times. The spinning down and spinning up can make some long-running jobs take a lot longer. Fortunately, Toshiba has a utility that will turn off the sleep function. You can download it here.

APOD Wallpaper: Fascinating!

Thursday, April 5th, 2012

If Mr. Spock had a big flat panel screen instead of being forced to look into a slot in a cereal box, he would have used APOD Wallpaper for his desktop background.  The Astronomy Picture of the Day website features a daily different collection of photons collected from the far reaches of the universe.  The awe-inspiring images from the depths of space are occasionally interspersed with space-related pictures of objects closer to home.  And each one comes with an explanation that adds to the wonderment.

You could visit the APOD website each day.  Or better,  Windows users can run the APOD Wallpaper app and receive a different breathtaking image on your desktop background each morning.  The app puts a little icon of the planet Jupiter in your Systray.  Right mousing on Jupiter pops up a menu that will bring up the APOD Wallpaper settings, show you the astronomer’s explanation of the day’s image, or take you to the APOD website.

The app is easy to install.  It comes in a Zip file.  Just unzip it into a convenient location (such as c:\Program Files\APOD), and run it.  In the Settings you can tell it to automatically run when Windows starts.  There are a couple of other Windows apps that do nearly the same thing.  Linux and Mac users have several choices, too.

Convert 3ds files to obj with Blender

Tuesday, January 24th, 2012


3DS is an aging binary interchange format for 3D models. OBJ is another aging, but ASCII-based format for 3D models.

Here is a simple Python script that converts one or more files from 3DS format to OBJ format using Blender:

# Convert 3ds to obj using Blender
# Run as follows:
#   blender -b dummy.blend -P -- file.3ds ...
# dummy.blend is just an empty Blender file needed as an argument.
# Put one or more .3ds files on the end of the command.
# The .obj files will be created with the same name (and path) as
# the .3ds file, but with the .obj extension.
# The export creates a .mtl file for each .obj file also.

import bpy
import sys
import os.path

for i in range(1, len(sys.argv)):
    if sys.argv[i] == "--":

for file in sys.argv[i+1:]:
    # Start with an empty scene

    # Read a .3ds file

    # Write a .obj file
    outfile = os.path.splitext(file)[0]+".obj"


Save the script code in a file named  You will also need a Blender file to use as a placeholder in the command line.  You can save an empty file from Blender, or use an existing one.  Assume it is called dummy.blend.

To convert 3DS files, use the following command:

blender -b dummy.blend -P -- file1.3ds file2.3ds file3.3ds

Tack on as many 3DS files to the end of the command as you want.

Note:  This assumes that dummy.blend and are in the same folder as your 3DS files.  If not, you will need to specify the proper path to each.

Win 7 Explorer Folder Display Bug

Thursday, June 9th, 2011

I am eagerly awaiting a fix for the Windows 7 bug that causes the Windows Explorer tree view to jump after you expand a node in the tree. Very irritating. The bug has been there since the first release of Win 7.

I had hoped the fix would be in SP1, but no. Let’s annoy Microsoft right back by voting to get this bug fixed.



I am cautiously optimistic that the workaround from Michael Noxfeld on 1-18-2012 may actually have fixed this problem!  It could just reappear on the next reboot, but I can always hope…

Click on the link to go to the bug page, then click on the Workarounds tab and scroll down a ways to find it.


Nope. That improved one aspect of the subtree display behavior but not the delayed jump back to a previous location. Still searching for a full solution.

Update 2:

I now believe the delayed jump was caused by the Network section of the tree view being refreshed. It takes a few seconds for all the machines on our network to be polled and added to the list. If I can launch Explorer with the Network subtree closed, this does not occur. So now I am religious about collapsing the Network section, so that when I launch a new Explorer window it won’t feel the need to refresh and cause the tree view to scroll at an unexpected time.

Open Command Prompt Here

Tuesday, May 10th, 2011

I still prefer the command line for many tasks. Sometimes it’s just faster. It can be a deterrent if you want to run some commands in a deeply nested folder, however. So I like the “Open Command Prompt Here” feature, which can be made available in Windows Explorer’s folder context menus.

In Windows 7 it is there, but hidden. Hold the Shift key and right mouse on a folder to see the context menu entry. In Windows Vista it is half there. Holding Shift while displaying the context menu only shows the hidden entry in the righthand pane of the Explorer Window. Prior to Vista, you need to use PowerToys or edit the registry to add the context menu item.

There is more information here.

What’s SVCHOST doing?

Saturday, November 27th, 2010

In a Windows CMD window you can type the following command:


to see what is being run by the various svchost.exe processes.

I was trying to track down what was using half my CPU when the machine should be idle. I was very thankful to find this blog entry. Turns out the culprit is the Pml Driver HPZ12 for my networked HP printer, which seems to put my machine into this state, maybe after someone has scanned documents and saved them onto a PC on the network.