Automatic locking for Windows Mobile
Written by Wojciech Kocjan   
I am using my HTC BlueAngel (MDA III) with WM6 system on a daily basis. One of the not so many annoying things I have with it is the following: I sometimes turn off my device without first locking the device via Today screen. When the device is turned on by me or by an incoming SMS/phone call, the touch screen and keyboard is not locked. This is mainly a problem if I have my phone in my belt clip and it turns itself on by itself.

I have written small script that handles automatic locking of the device. I have successfully tested that my WM6.0 is properly locked both when I turn on the device as well as when a call comes in. I have also made it lock my device after boot up - this is handy if you want to reboot the device, do not have any password and don't want to wait for the reboot to finish. It is written MortScript. The following things are needed in order to run the script:
  • MortScript installed to create scripts
  • lock.exe binary - can be downloaded from lock.zip

Unpack the lock.exe binary as \Program Files\lock.exe. Then create a script called \Program Files\OnWindowsStartup.mscr with the following content:
Initialize notification about power on events
# Remove & Install script to be run on power on
RemoveNotifications("\Program Files\OnPowerOn.mscr")
RunOnPowerOn("\Program Files\OnPowerOn.mscr")

# Lock the device
Sleep(5000)
Run("\Program Files\lock.exe")

Unpack the lock.exe binary as \Program Files\lock.exe. Then create a script called \Program Files\OnWindowsStartup.mscr with the following content:
Code run on every power on
# Wait for a second and lock the device
# (does not work without the Sleep)

Sleep(1000)
Run("\Program Files\lock.exe")

Next you need to create a shortcut in \Windows\StartUp directory which should point to \Program Files\OnWindowsStartup.mscr file. This can be done using Total Commander for PocketPC or any other file manager.

That's it - soft reset your device and it should now be locking by itself.

If anything fails, create the following script anywhere with .mscr extension and run it:
Uninstallation of OnPowerOn script
# Remove script to be run on power on
RemoveNotifications("\Program Files\OnPowerOn.mscr")

Hope you all like this script!