Posts tagged ‘scripting’

ActiveSync Scripting

The following is a nice? sample for an automation task. This batch will be executed every time a device connects to your PC via ActiveSync. You will need the itsutils.

As you can read, the batch (script) first tries to check, if it has already been run on the device. This is done by looking for a file called “\OnConnect.done”. In real, the batch deletes a local file (line 13) “OnConnect.done” and then simply copies the file from the device (line16). If the file is found, this device has been already processed (line 17) and the batch gos on with line 66.

If the file is not found, the batch continues with setting the registry changes. It uses saved REG files and the nice tool pregutl to do it remotely (line 22 to 24). After doing the changes, the device will be queried for different registry keys which will be saved to database.txt for later use. The registry keys platform (line 29) and version (line 30) are available on all devices, but OSBuildInfo (line 59) and system (line 48) are only available on CK3x or 7xx.

So in line 33, we try to find the model string for CK3x devices and in line 39 for CN2 devices. In line 43 and 44 we will use the saved model names to jump over the part, that is only valid for PPC (7xx): dump psminfo.txt into database.txt. The OSBuildInfo registry is only been executed for CK3x models.

Finally we put a OnConnect.done onto the device, so we later know, that it was handled. At the very end, we sync the time of the device with the PC.

Continue reading ‘ActiveSync Scripting’ »

PC ActiveSync can be used to automate tasks on device connection

You can have several apps started every time a device connects via ActiveSync on your PC. To enable this, you have to enter the application(s) to start in your PC Windows registry:

REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\AutoStartOnConnect]
"OnConnect"="\"c:\\windows\\system32\\cmd.exe\" /c d:\\OnConnect\\install.bat"

In this example, the batch file d:\OnConnect\install.bat will be launched every time a device connects via ActiveSync. If you use the itsutils, you can specify a list of commands executed against the connected device. In example, you can use the following install.bat (assuming that all tools and files are in d:\OnConnect) ot alwayss install certain files onto the device.

@echo on                 
pause                      
d:
cd d:\OnConnect
pput -f -v _0000_comp_itcivacn2.cab "\DiskOnChip\Persistent Copy\CabFiles\_0000_comp_itcivacn2.cab"
pput -f -v userApp_WCE4.ARMV4.cab "\DiskOnChip\Persistent Copy\CabFiles\IuserApp_WCE4.ARMV4.cab"
pput -f -v sqlce.wce4.armv4.cab "\DiskOnChip\Persistent Copy\CabFiles\sqlce.wce4.armv4.cab"
pput -f -v System_SR_enu.cab "\DiskOnChip\Persistent Copy\CabFiles\System_SR_enu.cab"
pregutl @region.reg
pause "ReBoot ?"
preboot
pause "*************** Finished **************************"
exit

These line copy some files to the device, change the registry with a regedit4 conform file (download sample), sync the time of the device to yours PC time and then perform a warmboot. Using the XDA tools (itsutils) there are many more possibilities. Especially usefull, as PocketPC devices do not support batch files on the device.