Community - SOTI MobiControl

Community - SOTI MobiControl

There's a new home for Articles. Find Articles on Our Product Support Page.

SOTI MobiControl Discussions


  • 0 votes 6 answers

    Javascript to push an application to the forefront if not locked

    Hi all, I'm looking for a javascript that I can run trough the task scheduler to a device that pushes an application to the forefront of the device every 5 minutes when the device is unlocked. (device is Android 14 / Xcover 6 pro Samsung) I have a task scheduler running now with a legacy script that brings the app to the forefront every 5 min (script is: start package.name). The problem with this is, even when the user locks the device, the script will bring the app before the unlockscreen. So i'm looking for a script that says: If PDA locked     no push application else if pda unlocked     start application every 5 min (bringing the application to the foreground every 5 min) else    no push application end Thank you for you help!

    SOTI MobiControl
    4 months ago
  • 0 votes 4 answers

    Javascript pre-install script

    I'm hoping someone can help me with this example script to be used as pre-install script in package studio to give the users a choise to click install when I update an app I want to know where I should put in the bundleID or package name. We can say that I want this to be used on soti surf (net.soti.surf). #!/usr/bin/env jsvar FIVE_MINUTES = 5 * 60 * 1000;var ONE_HOUR = 60 * 60 * 1000;var buttonLabels = ['Install now', 'Install in 5 minutes', 'Install in 1 hour']; if (isAppRunningInForeground('com.acme.importantapp')) {    mobicontrol.message.createInfoDialog('Would you like to install ImportantApp?')        .withButtons(buttonLabels[0], buttonLabels[1], buttonLabels[2])        .withCallback(onConfirm).show();} function onConfirm(result) {    if (result.buttonIndex != null) {        switch (buttonLabels[result.buttonIndex]) {            case 'Install now':                installImportantPcg();                break;            case 'Install in 5 minutes':                setTimeout(installImportantPcg, FIVE_MINUTES);                break;            case 'Install in 1 hour':                setTimeout(installImportantPcg, ONE_HOUR);                break;         }    }} function installImportantPcg() {    // Do nothing - the normal return from the script will launch the package installation} function isAppRunningInForeground(app) {    return mobicontrol.app.foregroundActivities.filter(activity => activity.packageName == app).length > 0;}

    Android
    6 months ago
  • 0 votes 8 answers

    Using writesecuresetting in Android Javascript script to update Private DNS Solved

    I've successfully used writesecuresetting in a legacy script to update the private_dns_mode and private_dns_specifier of phones running Android 13 and Android 14. Here's a working example: writesecuresetting -glo private_dns_mode hostnamewritesecuresetting -glo private_dns_specifier profilename.dns.nextdns.io However, I want to write a script that periodically checks to ensure that setting is still set, and corrects it if the user changes it. Also, I want to change the DNS specifier string based on the phone name and various other settings. I'm comfortable writing the necessary javascript logic, but I can't find a way to run writesecuresetting to change the setting. This seems like a significant oversight (either in the API design or on my part), and adding this would open all sorts of scripting possibilities. This may be an XY problem, so feel free to point me to a better way to do this. Edit: Just realizing this would be entirely possible if there was an API to run shell commands. That would open up all sorts of opportunities for more powerful scripting.

    Android Scripting
    7 months ago
  • 0 votes 7 answers

    How to script for change vibrate mode to ring mode.

    I want to send script to change notification from muted or vibrate to ring mode , what script to set that

    Android
    a year ago
  • 0 votes 2 answers

    Javascript API and Kiosk

    Hi All, I dont think the documentation makes it clear, so I thought Id ask here. Is the MobiControl Javascript API accessible/usable in a kiosk html template? Thanks James

    SOTI MobiControl
    a year ago
  • 0 votes 2 answers

    Sendintent via Javascript Solved

    Hello community, I have to implement a package script for Android devices which have to use a sendintent in relation to the OS version  of the calling device (>10 yes, otherwise not). The legacy scripting is really limited in logical branching. So I decide to use Javascript for implementation. So my question, is there a way to send an intent from Javascript on the device or to trigger a sendintent from there?  Thanks for any comment! Kind regards     Kersten

    Android Scripting
    a year ago
  • 0 votes 3 answers

    How to send “Enter” key with legacy script or Javascript Solved

    I have case for open App and execute App by start app and then send enter key  for execute application but I have not found script to do that , please advise me for this case

    Android
    a year ago
  • 0 votes 3 answers

    Javascript to set Static IP Address for Android Device

    i have use case that I have android tablet about 10000 items by each every tablet have own ipaddress and i have  ini file to save tablet number,  i want to set static ipaddress for every tablet  example tablet 1  id 0001  static ip address is 111.100.101.111  tablet 2 id 0001  static ip address is 111.100.102.111   tablet 3  id 0001  static ip address is 111.100.103.111   tablet 4  id 0001  static ip address is 111.100.104.111   tablet 5  id 0001  static ip address is 111.100.105.111   how to do that with javascript 

    Android
    a year ago
  • 0 votes 10 answers

    Getting a device's IP address with the Javascript API Solved

    Is there any way to get a device's IP address using SOTI's Javascript API? When I call the below function from within the API, I get back "undefined", but getting the same info using the %HOSTNAME% macro using legacy scripting returns an IP, is there anything I'm doing wrong here? var ip = mobicontrol.network.IpAddress.hostName; mobicontrol.log.info(""+ip); The log was just to test what value gets returned from the variable above.

    Android Scripting
    a year ago
  • 0 votes 5 answers

    javascript to create folder and create ini file when folder and file not exist

    Hi SOTI Comminity I new for javascript and i have use case that I will check folder and file  by if not found folder i will create folder 'sdcard/SOTI' and create file 'sdcard/SOTI/info.ini' how to do with javascript? I try  checkFolder(); function checkFolder() { var foldercheck = new mobicontrol.io.File('/sdcard/.SOTI'); if (foldercheck.exists) { mobicontrol.log.info('/sdcard/.SOTI exists');   }     else {  mobicontrol.log.info('/sdcard/.SOTI not exist.') newFolder(); }; } newFolder(); function checkFolder() { var file = new java.io.File('/sdcard/.SOTI'); var path = file.mkdir(); } But error not module java My SOTI server version 15.3 and SOTI Client verson 2024.0.4 Build 1056

    SOTI MobiControl
    a year ago
  • 0 votes 11 answers

    Can Built javascript file as pcg package and add to profile for execute after installed profile

    HI SOTI Community I have use case that   i want to send script (javascript) to all device as profile for end user input text to file. so, i do this 1. built pcg file with javascript file (file.js)  2. add pcg file to profile 3. assign to clients but script not working how to do or have another solution. this script #!/usr/bin/env js     inputStore(); function inputStore() {     mobicontrol.message.createTextPromptDialog('รหัสร้าน 5 หลักของคุณคือ?')         .withCallback(onConfirm).show(); } function onConfirm(result) {     var storeId = result.inputText;     if (isValidStoreId(storeId)) {         var stl = storeId.length;         var mcsetupFile = new mobicontrol.io.File('/sdcard/Documents/mcsetup.ini');         if (mcsetupFile.exists) {             var data = mcsetupFile.readText();             var keyText = "StoreID=";             var ktl = keyText.length;             var idx = data.indexOf(keyText);             var oldStoreId = data.substring((idx + ktl), idx + ktl + stl);             var offset = stl;             if (!isValidStoreId(oldStoreId)) {                 offset = 0;             }             var result = data.substring(0, idx + ktl) + storeId + data.substring(idx + ktl + offset);             mcsetupFile.writeText(result);         }     } else {       mobicontrol.message.createInfoDialog('Invalid store:'+storeId).show();    inputStore(); //repeat input       //mobicontrol.log.info('Invalid store:' + storeId);     } } function isValidStoreId(storeId) { return ((typeof storeId === 'string' && !isNaN(storeId)) && storeId.length == 5)};   My server version Version: 15.3.3.1065

    SOTI MobiControl
    a year ago
  • 0 votes 5 answers

    Trigger Package from MobiControl JavaScript is not working within package

    Hello, I have a solution that consists of three steps, split between two packages: Package 1:1. (Pre-install, Legacy) Download a .txt file from ftp.2. (Post-install, JavaScript) Process file and identify specific row, to be used for package 2. (Verifies each row with build number and modifies a provision.xml based on it) Package 2:1. (Post-Install, Legacy), performing an intent, invoking the provision.xml based on result from Package 1. The problem is that if I send all these three steps manually via "Send Script" on a device, it works flawlessly. But when I have built it as packages in MobiControl Package Studio, everything works except the command: "mobicontrol.packages.install('/sdcard/Download/package.pcg')" It does not give any error or anything.And that is only when it is built in a package. Do anyone have any ideas on how to resolve this? Can anyone replicate the issue?Have a package with a JavaScript post-install that starts another .pcg file. Info on the device I have tested on; MobiControl Version: 2024.0.0.1074 Agent på enheten: 2024.0.0.1005 Thanks in advance

    Android Scripting
    2 years ago
  • 0 votes 4 answers

    Launch javascript from a lockdown menu item Solved

    Hello, i know that we can use something like the below to launch a script from the lockdown menu if we add it as a custom itemscript:///scriptPathis there a way we can do this with javascript files? i have a java script file that i can successfully send to my devices and get the intended result. it works like a charm, i want to be able to leverage this by adding it as lockdown item

    Android Scripting
    2 years ago
  • 0 votes 2 answers

    Setting system language with javascript Solved

    Hello there,  I'm trying to set the system language of a device with javascript. As you can see in the js documentation, there is already an example script for it. I tried the example but I'm getting following error message: Custom log (Set locale failed with status code NOT_SUPPORTED) I used following example script in the js documentation: https://www.soti.net/mc/help/javascriptapi/en/mobicontrol.intl.Locale.html var locale = new mobicontrol.intl.Locale("en", "CA"); try { mobicontrol.intl.setLocale(locale); mobicontrol.log.info('Locale set.'); } catch (err) { mobicontrol.log.error('Set locale failed with status code ' + err.statusCode); }   MobiControl version: 15.5.1.1010 Agent Version: 15.4.2.1025

    Android Scripting
    2 years ago
  • 0 votes 3 answers

    Running legacy commands from a file Solved

    Hello, Im currently looking into a way to execute script command that would be stored on a device to standardize execution script for our patching process. The current script contains name of the file as well as version so I have to change the script every time a  change to package is done. Is there a way to have script stored in a file, for example *.cmd file, and execute the script inside this file either through legacy commands or Javascript?

    SOTI MobiControl
    2 years ago

Top 3 Contributors of The Week

View All

Earn Contributor Badge

More info
  • Diamond
    Diamond New !

    Top-tier experts who are delivering outstanding content. Should have more than 7000 points.

  • Platinum

    Experts who are consistent with great content. Should have more than 1000 points

  • Gold

    Highly experienced members with valuable inputs. Should have more than 700 points

  • Silver

    Beginners taking the initiative. Should have more than 500 points