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.
rem use database.txt template file, if no database.txt exists
if EXIST DataBase.txt goto OldDatabase
echo "Creating new database"
copy DataBase.tmpl DataBase.txt
echo "Using old database"
echo "auto calibrating device..."
pput -f NoWelcome.exe \NoWelcome.exe
echo "checking if already processed device..."
REM check if already processed
REM delete the local check file
del OnConnect.done >NUL
rem create a new local bak file
echo onconnect >OnConnect.bak
REM try to load the checkfile from device
pget \OnConnect.done >NUL
REM the database will be
if exist OnConnect.done (
) else (
echo "This device has already been processed"
REM put device in database
echo "building a new database entry..."
rem Copy DumpMac util to device
pput -f DumpMac.exe \DumpMac.exe
rem start DumpMac util on device
rem delete local file
del DumpMac.txt >NUL
rem download DumpMac.txt from device
rem copy DumpMac.txt at end of database.txt
type dumpmac.txt >>database.txt
rem put flag file on device to avoid duplicate processing
pput OnConnect.bak \OnConnect.done
REM uncomment, if you like to get a list of installed apps
REM pregutl HKEY_LOCAL_MACHINE\SOFTWARE\Apps >>database.txt
REM psynctime will be executed always
echo "syncing time..."
rem pause DEBUG
rem close this
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
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
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.