[Windows Mobile Software Development] myfingershurt:
Auto-prevent Exchange security policy pushes

So, Mortscript is an excellent tool; I started using it a couple days ago with the goal of automatically preventing Exchange security policies form being pushed onto my phone every 24 hours. I was tired of having to set the password, change the registry entries, and then remove the password every day. Zenyee Stay Unlock was cool, but I still had to unlock the phone after every reboot - which was annoying depending on where I had to reboot...!

So, here's a script that takes care of it for you! I found that if I kept the update rate fast - a couple seconds or so - the device rarely caught the policy change and forced a password change. However, I'd rather this be a very low-overhead script, so I gave it the ability to automatically get you out of the password dialog. It currently checks once every 15 seconds if the security policy has been pushed.

Here's the script - I like to have the notification message at the end so I know when it happens, but it is not necessary... I also put a shortcut to this script in my startup folder.

(To test, open a registry editor after launching the script and set HKLM\Security\Policies\00001023 to a value of "0" - security policy Enabled)

#Auto prevention of Exchange security policy enforcement...
SleepMessage( 3, "Auto-prevention of Exchange security policy enforecment v0.2 by Chris Paiano, 3/12/2010 - cpeproto.com" )
While(1)
If( RegRead("HKLM", "Security\Policies\Policies", "00001023") = 0 )
#Security policy has been enabled again!
#Disabling Exchange security policy:
RegWriteDWord("HKLM", "Security\Policies\Policies", "00001023",1)
#Disabling inactivity timeout:
RegWriteDWord("HKLM", "Comm\Security\Policy\LASSD\AE\
{50C13377-C66D-400C-889E-C316FC4AB374}", "AEFrequencyType",0)
#Removing password complexity enforcement:
RegWriteDWord("HKLM", "Comm\Security\Policy\LASSD\LAP\lap_pw", "PasswordComplexity",2)
#Allowing 0-length passwords:
RegWriteDWord("HKLM", "Comm\Security\Policy\LASSD\LAP\lap_pw", "MinimumPasswordLength",0)
#Disabling "ForceTimeout":
RegWriteDWord("HKLM", "Comm\Security\Policy\LASSD\AE\
{50C13377-C66D-400C-889E-C316FC4AB374}", "ForceTimeout",0)

sleep(2*1000)
curWindowTitle=ActiveWindow()
curProcessTitle=ActiveProcess()

While( curProcessTitle eq "services.exe" )

If( curWindowTitle eq "Update Required" )
#curWindowTitle=Update Required #curProcessTitle=services.exe
SendOK( "Update Required" )
sleep(2*1000)
curWindowTitle=ActiveWindow()
curProcessTitle=ActiveProcess()
EndIf

If( curWindowTitle eq "Settings" )
#curWindowTitle=Settings #curProcessTitle=services.exe
Close(curWindowTitle)
sleep(2*1000)
curWindowTitle=ActiveWindow()
curProcessTitle=ActiveProcess()
EndIf

If( curWindowTitle eq "Password Error" )
#curWindowTitle=Password Error #curProcessTitle=services.exe
SendOK( "Password Error" )
sleep(2*1000)
curWindowTitle=ActiveWindow()
curProcessTitle=ActiveProcess()
EndIf

RedrawToday

EndWhile

SleepMessage( 3, "Exchange security policy has been reset again! Registry entries have been reset.", "...Damn Exchange!", 1 )
EndIf

sleep(15*1000)

EndWhile

...and the below script is a simple one to kill the above script, assuming it is named "\Storage Card\Apps\mortscripts\AutoPreventSecPol.mscr"

(It is, after all, an endless loop script and you may want to stop it at some point.)

KillScript("\Storage Card\Apps\mortscripts\AutoPreventSecPol.mscr")
Message("Killed script AutoPreventSecPol.mscr")

I was looking for this but couldn't find anything posted anywhere - so hopefully I'm not reinventing the wheel here. Hope someone else finds this as useful as I have!

Edit: Forgot to mention, this was developed and tested on Windows Moblie 6.5.5 - NFSFAN's v1.05 custom ROM, on an Alltel HTC Touch Pro.