通过.ini文件自动命名SOTI设备

时间:2014-02-06 16:19:15

标签: soti

我正在尝试使用soti脚本来获取摩托罗拉设备的嵌入式序列号,并使用此编号在ini文件中查找自定义资产编号。然后将此资产编号作为soti注册表堆栈中的DeviceName写回设备注册表。

ini文件的格式为: -

10184522501228 = CITY7600A

我使用的代码是: -

    ;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

此代码使用序列号确定,但不会交换资产编号并重新写入soti reg。

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

事实证明以下行导致错误...

:assetfound
set MyAsset=substring %MyAsset% 4 -1

-1导致资产被清理,当我使用以下它完美地工作

:assetfound
set MyAsset=substring %MyAsset% 4 10