Auto naming of SOTI device via a .ini file

I am trying to use soti script that will take the embeded serial number of a Motorola device and use this number to look up a custom asset number in an ini file. Then write this asset number back into the devices registry as the DeviceName in the soti registry stack.

The format for the ini file is:-


The code i am using is:-

    ;read registry for Serial Number
    set MySerial=REG://HKEY_LOCAL_MACHINE\Software\MSP\IdentityAttributes?VN=serial
    showmessagebox %MySerial%

    ;Lookup in INI
    set MyAsset=INI://\temp\CityMC70Serial2Asset.ini?SC=Serial&NM=%MySerial%
    showmessagebox %MyAsset%
    set MyAsset=N/A%MyAsset%

    if not %MyAsset%==N/A goto assetfound
    set MyAsset=%MySerial%
    goto continue

    set MyAsset=substring %MyAsset% 4 -1

    ;Set in registry for Customer Data
    regset HKEY_LOCAL_MACHINE\Software\Apps\SOTI\MobiControl\PDB\Device\DeviceName?VD=MyAsset

    ;rename device to asset tag
    \windows\startup\CommLoader.exe -n %MyAsset%
    \windows\startup\CommLoader.exe -n %MyAsset%

    reset /s

This code takes the serial number ok but will not exchange for the asset number and re write to the soti reg.

Any help would be greatly appreciated.


It turns out that the following line was causing the error...

set MyAsset=substring %MyAsset% 4 -1

The -1 was causing the asset to be scrubbed, when i used the following it worked perfectly

set MyAsset=substring %MyAsset% 4 10

Need Your Help