Click here to Skip to main content
15,884,794 members
Articles / Programming Languages / C++
Tip/Trick

ActiveSync Scripting

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
3 Mar 2010CPOL1 min read 10.7K   2  
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...
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.



line text
1234567891011121314151617181920
2122232425262728293031323334353
6373839404142434445464748495051
5253545556575859606162636465666
768697071727374

@echo offclsecho #############################
#########################################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 \OnConnectecho 
"checking if already processed device..."
REM check if already processedREM delete the check 
file@del OnConnect.done >NULLecho onconnect
>OnConnect.bakREM try to load the checkfile@pget 
\OnConnect.done >NULLif exist OnConnect.done goto 
OldDevicegoto NewDevice:NewDeviceecho "####### 
New Device #######"echo "setting region..."
pregutl @region.regecho "setting timezone..."
pregutl @timezone.regREM put device in databaseecho. 
>>database.txtecho "building database entries...
"echo ####### >>database.txtpregutl HKEY_LOCAL_MACHINE\
Platform >>database.txtpregutl HKEY_LOCAL_MACHINE\SOFTWARE\
Intermec\Version >>database.txtREM only PPC device have 
Intermec\SystemREM check for ck3xpregutl HKEY_LOCAL_MACHINE\
Platform | 
FINDSTR "CK3"if errorlevel 1 goto cont1if errorlevel 0 set 
Model="CK3X":cont1REM CN2 does not have OSBuildInfo as 
CK3xREM check for CN2pregutl HKEY_LOCAL_MACHINE\Platform | 
FINDSTR 
"CN2"if errorlevel 1 goto cont2if errorlevel 0 set 
Model="CN2":cont2if "%Model%"==""CK3X"" 
goto CK3xif "%Model%"==""CN2""
 goto CN2REM PPC only:NoCK3x:NoCN2pregutl HKEY_LOCAL_MACHINE\
 SOFTWARE\Intermec\System >>database.txtREM look for 
 PSMInfodel PSMInfo.txtpget "\Flash File Store\PSMInfo.txt"
 if NOT EXIST PSMInfo.txt goto NoPSMtype PSMInfo.txt 
 >>database.txtecho. >>database.txtREM if you 
 like to get a listing of the cabfiles uncomment following 
 lineREM pdir "\Flash File Store\Persistent 
 Copy\Cabfiles\*.*" >>database.txtgoto 
 NoPSM:CK3xpregutl HKEY_LOCAL_MACHINE\SOFTWARE\Intermec\
 OSBuildInfo 
 >>database.txt:NoPSM:CN2pput OnConnect.bak \
 OnConnect.doneREM the database will be filled onceREM 
 reg changes will also done only for new devicesREM 
 psynctime will be executed always:OldDeviceREM uncomment, 
 if you like to get a list of installed appsREM pregutl 
 HKEY_LOCAL_MACHINE\SOFTWARE\Apps >>database.txtecho 
 "syncing time..."psynctime@echo onREM pause DEBUG:EXITexit


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:00000001Type=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"

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --