Programmatically Enable/Disable AIR Autoupdate from an AIR Application

Adobe AIR has an amazing Automatic Updates Checker built in.  But Adobe hasn’t provided any controls to enable/disable this feature, though its enabled by default. Adobe provides an AIR application called the Settings Manager to handle this. This can also be done programmatically.

Download [download id="1"].


<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
 layout="horizontal" height="100" width="600"
 verticalAlign="middle" fontFamily="Georgia" color="#000000"
 backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #FFFFFF]"
 showStatusBar="false" horizontalScrollPolicy="off" verticalScrollPolicy="off" viewSourceURL="srcview/index.html">

 <mx:creationComplete>
 <![CDATA[

 if (Capabilities.os.indexOf("Windows") > -1 || Capabilities.os.indexOf("Linux") > -1) {
 f = new File(File.applicationStorageDirectory.nativePath + "/../../Adobe/AIR");
 } else if (Capabilities.os.indexOf("Mac") > -1) {
 f = new File(File.applicationStorageDirectory.nativePath + "/../../../Application Support/Adobe/AIR");
 } else {
 this.removeChild(btn);
 status_txt.text = "Can't do it [:(] Unsupported OS or something...";
 }

 if (f != null)
 {
 f = f.resolvePath("updateDisabled");
 if(f.exists) {
 //Auto updates is disabled
 btn.label = "OFF";
 } else {
 //Auto updates is enabled
 btn.label = "ON";
 btn.selected = true;
 }

 }
 ]]>
 </mx:creationComplete>

 <mx:Script>
 <![CDATA[
 import mx.controls.Alert;

 private var f:File;

 private function enableDisableAutoUpdater( enable:Boolean ):void {
 if(enable) { //Enable Auto updates
 if (f!= null) {
 //f = f.resolvePath("updateDisabled");
 if (f.exists) { //If the updateDisabled file exists
 try    {
 f.deleteFile(); // Delete it
 } catch (error:Error) {
 Alert.show("Something went wrong!");
 }
 }
 }
 btn.label = "ON";
 } else {
 if (f !== null)    {
 //f = f.resolvePath("updateDisabled");
 if (!f.exists) { //If the updateDisabled file doesn't exist
 try    {
 var fileStream:FileStream = new FileStream();
 fileStream.open(f, FileMode.WRITE); //Create it
 fileStream.close();
 } catch (error:Error) {
 Alert.show("Something went wrong!");
 }
 }
 }
 btn.label = "OFF";
 }
 }

 ]]>
 </mx:Script>

 <mx:Text id="status_txt" text="Adobe AIR - Automatic updates is" fontSize="24"/>

 <mx:Button id="btn" label="ON" toggle="true"
 click="{enableDisableAutoUpdater(event.currentTarget.selected);}" fontSize="24" width="80"/>

</mx:WindowedApplication>

Leave a Reply


Creative Commons License