Saturday, March 24, 2007

 

Pevent duplicate script execution with a lock / critical section

Recently I wanted to prevent a batch script from being executed multiple times concurrently. Functionality to prevent this is pretty easy. We can create a file as a lock and check for its existance. If the file exists we know the script is running. By deleting the file at the end of the script we allow other script instances to start.

Here's some sample code:


@echo off

SET LOCK=.%0.lock

if exist %LOCK% (
echo Script is locked
pause
goto :EOF
)

echo > %LOCK%

echo In main program
echo In main program
echo In main program
echo In main program
echo In main program
echo In main program
echo In main program
echo In main program
pause

del %LOCK%

Thursday, March 1, 2007

 

FIX: Microsoft Word 2003 Backspace Doesn't Work

I just came across some really annoying behaviour with Word 2003 (I dare say it's the same with 2000 and XP too). I somehow managed to change the behaviour so when I selected some text and pressed backspace the text remained there and the cursor moved to the start of the selection. Equally if I selected a word and tried typing over it the original word remained there and the new word would be typed immediately before it.

Solution: Turn on 'Typing replaces selection' mode.

Options -> Edit tab -> Tick 'Typing replaces selection'

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]