Updating/Writing to INI file on Android

Solved

Hi all, I have been working with a Honeywell CT40 to iron out the configuration before we roll it out to our end users and the last thing I am struggling with is having the built-in SmartTE app use the device name for the WSID. I figure the best way to do with would be to write the SOTI %MCDEVICENAME% to the staylink.ini file where the app hosts this file.

Is there any way to script this out? This realistically only needs to be done either when the device is configured or renamed

2 years ago
Android Scripting
ANSWERS
RS
Rafael Schäfer
2 years ago

Something like this?
Use sendscript command (Javascript) / Task profile or package (.js file! not as a script):

var ini = require('ini');
var iniFile = new mobicontrol.io.File('/path/ininame.ini');
var config = ini.parse(iniFile.readText());
config.sectionname = { keyname: 'value' };
iniFile.writeText(ini.stringify(config));
Solution
RS
Rafael Schäfer
2 years ago
MD
Matt Dermody Diamond Contributor
2 years ago

SmartTE has Managed Configuration support but the exposed parameters are relatively limited to mostly connectivity details like host URL and port. There are a lot more app configuration parameters that can be set via the external ini file today than what they have exposed through Managed Config. 

CO
Chris Oneil
2 years ago

Rafael, I made the necessary modifications to the above script and saved it as a JS file. What is the best way to build a package within MCStudio to deploy it? as a pre-install script?

RS
Rafael Schäfer
2 years ago

You have to provide it not as a script but as a file and check that it has to be executed afterwards i think.
But be aware of what Matt wrote. It can be that Mobicontrol doesn't have access to the ini-file to change it.

Can you define in the app config where the ini file to be used is located or trigger it to watch for an ini file in a different location to read and parse the information itself to the correct one?

Then you can, as Matt wrote, provide an ini file, change the relevant values with the script and put it in that accessable location or trigger the app to use this specific "new" ini file.

But as far as i don't know how this app behaves and what functionalit is included or not it's hard to help further. But maybe Matt or someone else has a deeper knowledge to this app (and maybe also related to Honeywell device itself).

CO
Chris Oneil
2 years ago

I reached out to StayLinked support and they sent me some locations where I could create a new INI file that the app checks for when it launches. I have tested that out with another modified version of the script you provided and it is all working great. Now I am just in the process of creating a package to deploy this to newly enrolled devices.

Thank you for all the help!

RS
Rafael Schäfer
2 years ago

Nice to "hear" that it helped and you get close to the final solution.

MD
Matt Dermody Diamond Contributor
2 years ago

One complexity to watch out for if you are on Android 11+ is that the staylink.ini file will be read in from public storage and then saved into the scoped storage of the app. The SOTI agent won't have the ability to read /write from the .ini file that is moved into scoped storage so you'd have to make the edits to the staylink.ini file in public storage before it is read in by the app. This may complicate your ability to make changes to the device name and have them automatically updated in the SmartTE config. 

G
GPMOD@SOTI
2 years ago

Hi Chris,

Thanks for posting on SOTI Pulse and thanks Rafael and Matt for responding to the post.

I am glad that you found a solution to this query. 


Kind regards,

Technical Support | SOTI Inc. |1.905.624.9828 | support@soti.net | www.soti.net |