Javscript would provide a navigation menu here. HOME

ActiveSync Scripting

  1. Catalog of connected devices
  2. List model, serial and MAC of connected devices

Sample 1: Catalog of connected devices

The following is a nice? sample for an automation task. This batch is like the one in Tipps. It 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.

 

line

text

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74
@echo off

cls

echo ######################################################################

echo #   autosetup script for ITC devices (CK3x, CN2x, 7xx)               #

echo #   will set registry keys for numberig format, timezone and DST     #

echo #   creates a database.txt file with relevant data of the devices    #

echo ######################################################################

D:

cd \OnConnect

echo "checking if already processed device..."

REM check if already processed

REM delete the check file

@del OnConnect.done >NULL

echo onconnect >OnConnect.bak

REM try to load the checkfile

@pget \OnConnect.done >NULL

if exist OnConnect.done goto OldDevice

goto NewDevice

:NewDevice

echo "####### New Device #######"

echo "setting region..."

pregutl @region.reg

echo "setting timezone..."

pregutl @timezone.reg

REM put device in database

echo. >>database.txt

echo "building database entries..."

echo ####### >>database.txt

pregutl HKEY_LOCAL_MACHINE\Platform >>database.txt

pregutl HKEY_LOCAL_MACHINE\SOFTWARE\Intermec\Version >>database.txt

REM only PPC device have Intermec\System

REM check for ck3x

pregutl HKEY_LOCAL_MACHINE\Platform | FINDSTR "CK3"

if errorlevel 1 goto cont1

if errorlevel 0 set Model="CK3X"

:cont1

REM CN2 does not have OSBuildInfo as CK3x

REM check for CN2

pregutl HKEY_LOCAL_MACHINE\Platform | FINDSTR "CN2"

if errorlevel 1 goto cont2

if errorlevel 0 set Model="CN2"

:cont2

if "%Model%"==""CK3X"" goto CK3x

if "%Model%"==""CN2"" goto CN2

REM PPC only

:NoCK3x

:NoCN2

pregutl HKEY_LOCAL_MACHINE\SOFTWARE\Intermec\System >>database.txt

REM look for PSMInfo

del PSMInfo.txt

pget "\Flash File Store\PSMInfo.txt"

if NOT EXIST PSMInfo.txt goto NoPSM

type PSMInfo.txt >>database.txt

echo. >>database.txt

REM if you like to get a listing of the cabfiles uncomment following line

REM pdir "\Flash File Store\Persistent Copy\Cabfiles\*.*" >>database.txt

goto NoPSM

:CK3x

pregutl HKEY_LOCAL_MACHINE\SOFTWARE\Intermec\OSBuildInfo >>database.txt

:NoPSM

:CN2

pput OnConnect.bak \OnConnect.done

REM the database will be filled once

REM reg changes will also done only for new devices

REM psynctime will be executed always

:OldDevice

REM uncomment, if you like to get a list of installed apps

REM pregutl HKEY_LOCAL_MACHINE\SOFTWARE\Apps >>database.txt

echo "syncing time..."

psynctime

@echo on

REM pause DEBUG

:EXIT

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"




List model, serial and MAC of connected devices

Here is one more sample. It will write the mdel code, the serial number, the network adapters and there MAC addresses to a tab delimited file.

Code

1 echo off
2 cls
3 echo ######################################################################
4 echo #   autorunconnect script for ITC devices (7xx except 73x)           #
5 echo #   will get Model Code, Serial Number and MAC address of a device   #
6 echo #   creates a database.txt file with data of the devices             #
7 echo ######################################################################
8 c:
9 cd \OnConnect
10
11 rem use database.txt template file, if no database.txt exists
12 if EXIST DataBase.txt goto OldDatabase
13 echo "Creating new database"
14 copy DataBase.tmpl DataBase.txt
15
16 :OldDatabase
17 echo "Using old database"
18 echo "auto calibrating device..."
19 pput -f NoWelcome.exe \NoWelcome.exe
20 prun \NoWelcome.exe
21
22 echo "checking if already processed device..."
23 REM check if already processed
24 REM delete the local check file
25 del OnConnect.done >NUL
26 rem create a new local bak file
27 echo onconnect >OnConnect.bak
28
29 REM try to load the checkfile from device
30 pget \OnConnect.done >NUL
31
32 REM the database will be filled once 
33 if exist OnConnect.done (
34 goto OldDevice 
35 ) else (
36 echo "This device has already been processed"
37 goto NewDevice
38 )
39
40 :NewDevice
41 :NoCalib
42 echo "...NoCalib.."
43 REM put device in database
44 echo. >>database.txt
45 echo "building a new database entry..."
46 rem Copy DumpMac util to device
47 pput -f DumpMac.exe \DumpMac.exe
48 rem start DumpMac util on device
49 prun \DumpMac.exe
50 rem delete local file
51 del DumpMac.txt >NUL
52 rem download DumpMac.txt from device
53 pget \DumpMac.txt
54 rem copy DumpMac.txt at end of database.txt
55 type dumpmac.txt >>database.txt
56 rem put flag file on device to avoid duplicate processing
57 pput OnConnect.bak \OnConnect.done
58
59 :OldDevice
60 REM uncomment, if you like to get a list of installed apps
61 REM pregutl HKEY_LOCAL_MACHINE\SOFTWARE\Apps >>database.txt
62 REM psynctime will be executed always
63 echo "syncing time..."
64 psynctime
65 echo on
66 rem pause DEBUG
67
68 :EXIT
69 rem close this
70 exit




Some Notes:

The script/batch is written to run from c:\OnConnect. Please patch it, if you want to run it from another place. You must change also change the PcTools\ActiveSyncOnConnectWINDOWS.reg file. Please adjust the windows dir in the reg file too, if c:\windows is not your windows dir.
REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\AutoStartOnConnect]
"OnConnect"="\"c:\\windows\\system32\\cmd.exe\" /c c:\\OnConnect\\install.bat"
You will also find reg files to disable/enable the Partnership dialog of ActiveSync in the PcTools dir of the download file.
REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services]
"GuestOnly"=dword:00000001

Code Comments

Lines 11-14 will copy a template file for the database containing the header line, if there is not already a database.
Lines 16-20 will auto calibrate the device. This will only work for known devices, see \NoWelcome.log.txt on device. This all is to avoid the manual calibration and Dr.Johnson test.
Lines 22-38 will check, if the device has already been processed. This is done by checking, if the file \OnConnect.done exists on the device. These lines should ensure, that you dont get a device listed several times in the database. You will get duplicate entries, if your device has been cold booted, as this removes all non-OS image files from the device.
Lines 40-57 will copy a tool called DumpMac to the device, execute it remotely and get the output file written by the tool.. The single DumpMac.txt is then appended to the database file. In line 57 the device will be 'marked' as allready processed.
Lines 59-66 will sync the time of the device to the PCs time. You can uncomment the line "REM pregutl HKEY_LOCAL_MACHINE\SOFTWARE\Apps >>database.txt", but this will change the layout of the database.txt and you will get problems using database.txt in excel.

Data

Model 
Serial Adapter Mac Adapter Mac
730B1E400400100 SN016710600222 BCMCF1 00:0b:6b:1a:f3:eb USB Cable: 00:00:00:00:00:00
741B6800E800N00 SN010390600008 LAN90001 00:10:40:0a:64:49 USB Cable: 00:00:00:00:00:00
760A42G2G100400 SN019590206057 LAN90001 00:10:40:02:bb:46 USB Cable: 00:00:00:00:00:00
751A6100E800N80 SN015100601578 SWLD26C1 00:02:78:4e:45:cf USB Cable: 00:00:00:00:00:00
CN2A11E11N2803 SN80083652003935313330343030313533 SWLD26C1 00:02:78:ef:26:7c USB Cable on COM5: 00:00:00:00:00:00
Download full sample (incl the itsutils) 
Updated 15. nov 2006