Reputation: 21
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:-
10184522501228=CITY7600A
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
:assetfound
set MyAsset=substring %MyAsset% 4 -1
:continue
;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.
Upvotes: 1
Views: 1537
Reputation: 21
It turns out that the following line was causing the error...
:assetfound
set MyAsset=substring %MyAsset% 4 -1
The -1 was causing the asset to be scrubbed, when i used the following it worked perfectly
:assetfound
set MyAsset=substring %MyAsset% 4 10
Upvotes: 1