There's a new home for Articles. Find Articles on Our Product Support Page.
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!
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;}
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.
I want to send script to change notification from muted or vibrate to ring mode , what script to set that
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
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
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
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
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.
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
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
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
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
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
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?
Top-tier experts who are delivering outstanding content. Should have more than 7000 points.
Experts who are consistent with great content. Should have more than 1000 points
Highly experienced members with valuable inputs. Should have more than 700 points
Beginners taking the initiative. Should have more than 500 points