ActiveSync Scripting

Print This Post Print This Post

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.

  1. @echo off
  2. cls
  3. echo ######################################################################
  4. echo # autosetup script for ITC devices (CK3x, CN2x, 7xx) #
  5. echo # will set registry keys for numberig format, timezone and DST #
  6. echo # creates a database.txt file with relevant data of the devices #
  7. echo ######################################################################
  8. D:
  9. cd \OnConnect
  10. echo "checking if already processed device..."
  11. REM check if already processed
  12. REM delete the check file
  13. @del OnConnect.done >NULL
  14. echo onconnect >OnConnect.bak
  15. REM try to load the checkfile
  16. @pget \OnConnect.done >NULL
  17. if exist OnConnect.done goto OldDevice
  18. goto NewDevice
  19. :NewDevice
  20. echo "####### New Device #######"
  21. echo "setting region..."
  22. pregutl @region.reg
  23. echo "setting timezone..."
  24. pregutl @timezone.reg
  25. REM put device in database
  26. echo. >>database.txt
  27. echo "building database entries..."
  28. echo ####### >>database.txt
  29. pregutl HKEY_LOCAL_MACHINE\Platform >>database.txt
  30. pregutl HKEY_LOCAL_MACHINE\SOFTWARE\Intermec\Version >>database.txt
  31. REM only PPC device have Intermec\System
  32. REM check for ck3x
  33. pregutl HKEY_LOCAL_MACHINE\Platform | FINDSTR "CK3"
  34. if errorlevel 1 goto cont1
  35. if errorlevel 0 set Model="CK3X"
  36. :cont1
  37. REM CN2 does not have OSBuildInfo as CK3x
  38. REM check for CN2
  39. pregutl HKEY_LOCAL_MACHINE\Platform | FINDSTR "CN2"
  40. if errorlevel 1 goto cont2
  41. if errorlevel 0 set Model="CN2"
  42. :cont2
  43. if "%Model%"==""CK3X"" goto CK3x
  44. if "%Model%"==""CN2"" goto CN2
  45. REM PPC only
  46. :NoCK3x
  47. :NoCN2
  48. pregutl HKEY_LOCAL_MACHINE\SOFTWARE\Intermec\System >>database.txt
  49. REM look for PSMInfo
  50. del PSMInfo.txt
  51. pget "\Flash File Store\PSMInfo.txt"
  52. if NOT EXIST PSMInfo.txt goto NoPSM
  53. type PSMInfo.txt >>database.txt
  54. echo. >>database.txt
  55. REM if you like to get a listing of the cabfiles uncomment following line
  56. REM pdir "\Flash File Store\Persistent Copy\Cabfiles\*.*" >>database.txt
  57. goto NoPSM
  58. :CK3x
  59. pregutl HKEY_LOCAL_MACHINE\SOFTWARE\Intermec\OSBuildInfo >>database.txt
  60. :NoPSM
  61. :CN2
  62. pput OnConnect.bak \OnConnect.done
  63. REM the database will be filled once REM reg changes will also done only for new devices
  64. REM psynctime will be executed always
  65. :OldDevice
  66. REM uncomment, if you like to get a list of installed apps
  67. REM pregutl HKEY_LOCAL_MACHINE\SOFTWARE\Apps >>database.txt
  68. echo "syncing time..."
  69. psynctime
  70. @echo on
  71. REM pause DEBUG
  72. :EXIT
  73. exit

Here is a sample of the database.txt

#######
[HKLM\Platform]
CodeName="SeaRay"
Model="730A"
Name="Intermec 740"
Software Build Number="4.95.1"
Target=dword:00000001
Type=dword:00000002

[HKLM\SOFTWARE\Intermec\Version]
IVA="iva_4.03.35.0998"
LScanner="1d-35-0-21"

[HKLM\SOFTWARE\Intermec\System]
BLVer="4.95"
FPGAVer="1.15"
KBVer="1.06"
MFGCode="730A1E4004001000"
OSVer="4.20.0"
SN="004210400008"
PSM Build v4.03 (05-12-2006) 

#######
[HKLM\Platform]
Build="3.00.00.0103"
CodeName="Gimli"
Model="CN2A"
Name="Intermec CN2"
Software Build Number="3.00.00.0103"
Type=dword:00000002
[HKLM\SOFTWARE\Intermec\Version]
IVA="iva_4.02.31.0691"

#######
[HKLM\Platform]
Build="3.00.00.0103"
CodeName="Gimli"
Model="CN2A"
Name="Intermec CN2"
Software Build Number="3.00.00.0103"
Type=dword:00000002

[HKLM\SOFTWARE\Intermec\Version]
IVA="iva_4.02.31.0691"
...

Leave a Reply