[Windows Mobile Software Development] howdykeith:
Tips and tricks for cab installs to storage card

As posted: Tips and tricks for cab installs to storage card

In the past there has been a limitation in the cab template for applications that need to kick off a script at startup or set off some scripts from the notification queue. Both of these issues have been tackled in the Treo Alerts beta 10 cab found here.

http://discussion.treocentral.com/sh...&postcount=930

Here is what was done to get it to work perfectly.

1) The install script checks whether installing to the storage card or not and if so the MortScript.exe is still installed on the device which all of the app's scripts will use.

Code:

# Make sure there is a MortScript.exe on the device for this app

# even if installing to the storage card

If ( Find( instPath, "\Storage Card" ) = 1 )

msPath = SubStr( instPath, 14 )

If ( NOT DirExists( msPath ) )

MkDir( msPath )

EndIf

Copy( instPath \ "MortScript.exe", msPath \ "MortScript.exe", 1 )

Else

msPath = instPath

EndIf

2) Use shortcuts that call this MortScript.exe directly to launch scripts. Use the /wait=15 parameter so MortScript will wait up to 15 seconds for the storage card to become available at boot time.

Code:

# install the app shortcuts. Use the MortScript.exe on the device

CreateShortcut( "\Windows\Start Menu\Programs\ALERTS.lnk",\

"""" & msPath \ "MortScript.exe"" """ & instPath \ "TREOSET.mscr""?ScriptIcons.dll,-124" )

CreateShortcut( "\Windows\StartUp\TA.lnk",\

"""" & msPath \ "MortScript.exe"" /wait=15 """ & instPath \ "ALERT CONTROL.mscr""?ScriptIcons.dll,-124" )

3) Once a script is launched it can call other scripts using CallScript. If you need to call a script using Run make sure you call it as a parameter of MortScript.exe. Here is an example of launching an app at install time.

Code:

# kick off the control script

KillScript( "ALERT CONTROL.mscr" )

Sleep( 2000 )

Run ( msPath \ "MortScript.exe", """" & instPath \ "ALERT CONTROL.mscr""" )

4) If you need to run a script from the notification queue make sure to call it as a parameter of MortScript.exe.

Code:

#Set when the script should run again, 2 minutes from the current time

Rerun = Timestamp()+120

RunAt( Rerun, msPath \ "MortScript.exe", "/wait=15 """ & myPath \ "REMIND.mscr""" )

If you need to remove it from the notification queue you do the same.

Code:

RemoveNotifications( msPath \ "MortScript.exe", "/wait=15 """ & myPath \ "REMIND.mscr""" )

5) When uninstalling the app make sure to remove the app installed MortScript.exe from the device via the uninstall.mscr. Also remove the shortcuts and kill any running scripts.

Code:

# Kill the control script

KillScript( "ALERT CONTROL.mscr" )

# If app was installed on the storage card then delete MortScript.exe on the device

# which was installed via the install.mscr

If ( Find( instPath, "\Storage Card" ) = 1 )

msPath = SubStr( instPath, 14 )

If ( DirExists( msPath ) )

Delete( msPath \ "MortScript.exe" )

RmDir( msPath )

EndIf

EndIf

# delete shortcuts

If ( FileExists( "\Windows\Start Menu\Programs\ALERTS.lnk" ) )

Delete( "\Windows\Start Menu\Programs\ALERTS.lnk" )

EndIf

If ( FileExists( "\Windows\StartUp\TA.lnk" ) )

Delete( "\Windows\StartUp\TA.lnk" )

EndIf

Following these steps will provide users of trouble free installs to the storage card.

Why not just have users install a common MortScript for all apps? Well the problem is that each app may require a different version of MortScript. Some scripts run only with 4.01 and others with 4.0. In fact if our cab installs follow the above steps you can have a common MortScript 4.0 installed and cab apps can use 4.01. I do this now since Xcast has issues with 4.01 and Treo Alerts uses many cool new features of 4.01. Best of both worlds.