How to abort a pkg install using js??

JW

Hi.

android tc52x 

mobicontrol 15.5

I'm using mobicontrol pk studio with a js file for pre-install script.

All is good except ...How do I use abortpkg in javascript?

I use mobicontrol.message.createYesNoDialog with .withCallback(onConfirm) but if they choose the No button, I don't know how to abort the pkg install.

Any ideas?

tks.

2 years ago
SOTI MobiControl
ANSWERS
RC
Raymond Chan Diamond Contributor
2 years ago

You might consider using an arbitrarily large timeout (e.g. years)  to a dummy empty callback function, which virtually delay infinitely the return of your javascript and actual launching of the package installation.

JW
James Wisecup
2 years ago

thanks Raymond.  That is something to consider.  

S
SAMOD@SOTI
2 years ago
S
SAMOD@SOTI
2 years ago

Hello James,

Thanks everyone for your posts on SOTI Pulse.

After asking internally regarding your inquiry, it seems that you cannot use JavaScript to aborting package installation. It may be an option, but we do not have a definite date/road map. 

What you want to achieve should be similar to "abortpkg" script commands, where we abort the installation of a package using JS, then it should be visible in MobiControl Web Console.

Thank you.

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

S
SAMOD@SOTI
2 years ago

Hello James,

You may create a support ticket, and we could attach a Developer Ticket with your use case, which may speed up the implementation of the already considered feature.

Thank you.

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

AP
Armando Pino
2 years ago

I figured out how to force the package to fail using an if/else statement inside a "pre-install" script. The "else" command will throw an error that aborts the package from executing. This will mark it as "Install Failed" in Mobicontrol if the condition in the "if" statement is not met.

The throw statement you need to do this is:

throw(mobicontrol.packages.Termination.ABORTED); 

I also included a syntax to log the currentSSID and prompt a message on the remote device to indicate the status of the package.

You can tear apart my code to achieve the results you are trying accomplish. Also, remove any of the mobicontrol.message or mobicontrol.log statements if you like. I only include them to give me a visual and log the results when testing the script out.

I was using it to check current network SSID and fail/log the package if it's not on my desired SSID. If it is on the desiredSSID it will trigger the rest of the package. That includes install applications, deploy files and/or trigger a post-install script.

//Below is the Pre-Install Script

#!/usr/bin/env js

var currentSSID = mobicontrol.network.ssid;
if (currentSSID == "DesiredSSID") {
    mobicontrol.message.createInfoDialog("SSID is GOOD we will begin installing the package! Current SSID is" + currentSSID).withTimer(5000).show();
    mobicontrol.log.info("SSID is GOOD we will begin installing the package! Current SSID is: " + currentSSID);
}
else {
    mobicontrol.message.createErrorDialog("Package FAILED due to wrong SSID! Current SSID is: " + currentSSID).withTimer(5000).show();
    mobicontrol.log.error("Package FAILED due to wrong SSID! Please ensure the device is connected to the appropriate SSID... Current SSID is: " + currentSSID);
    throw(mobicontrol.packages.Termination.ABORTED);
}