0 Replies Latest reply on Sep 5, 2015 2:55 PM by SourceSkyBoxer

    How do I create simple custom Installer with Air Captive Runtime with BoxedApp Packer?

    SourceSkyBoxer Level 1

      Hello Sirs & Ladies,

       

      Forword:

      Who wants to manage Key / Serial onto our custom installer ( used packed Air Captive Runtime ). I have good ideas for Adobe Air Cutsom Installer. We don't want to need unknown files like "minetype", "hash" from native air installer.I know they don't like this. Don't worry! I improve own custom installer like they manage own custom installer.

       

      BoxedApp Packer is a good packer into standalone Windows binary ( *.exe ) For Mac OS X i recommend "MacPack" or other program can make to standalone application under Mac OS X. For Linux: You need to install latast version of Wine Packages or Mono Package and you can example shell like if else statement for existing "wine" or "mono" than you would like to create own linux binary like we use mkbundle or other program can wine or mono with windows binary data into own linux binary.

       

      Warning for Linux OS:

      If you retry to install custom installer and any application won't write that you need to write shell script with gksudo or kdesudo than it opens custom installer. Or like Android OS.. I think Linux works like Android.

       

      For Mac OS X too

      Maybe custom installer need super user right like cocoasudo or machsudo i don't know because i haven't machine.

       

      For Windows OS:

      Simple with mt.exe <airpackedcustominstaller>.exe.manifest Request "RunAsAdmin" or "ElevatedAdministrator"

       

      For Android OS:

      Call and call back with native process with /system/bin/su or /system/xbin/su

       

      For iOS:

      I haven't yet to test.. Because i have not iPhone or iPad. Sorry

       

      Example about my initial custom installer:

       

      Choose path to your install directory:

      Picture 1

       

      Click button "Install" and it will write dates of application content and it creates shortcut

      Picture 2

       

      Close custom installer or you want to run application?

      Picture 3

       

      Hurray initial application started.

      Picture 4

       

      Question?

      Where is shortcut of installed application?

      You find it:

      Picture Shortcut

       

      Where is installed application content?

      You find like Step 1: "Choose path to your install directory:"

      For example C:\Program Files (x86)\Example Application

      Picture Application directory

      Picture Application content

       

      If you want to test my real custom installer than you can download my file.  Don't worry! It is a trusted air packed application.

       

      That is a good result because Adobe Air makes very better than Zinc Studio 4.0.22 I miss Zinc Studio. Bye bye Zinc Studio and i give flower to Zinc Studio in church yard. Thanks for nice time.

       

      Requirements:

      BoxedApp Packer

      UPX Easy GUI

      Air Captive Runtime ( create frist than you create Air Native Runtime. Because it is very nice tricky by Ukranian ( He has created frist Air Captive Runtime than he created Air Native Runtime with Ane and both xmls and swf into Captive Runtime. )

       

      Coding:

      Create project and you like this:

      "custominstaller.mxml"

      <?xml version="1.0" encoding="utf-8"?>

      <mx:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"

        xmlns:mx="library://ns.adobe.com/flex/mx"

        layout="absolute" showStatusBar="false">

        <fx:Script>

        <![CDATA[

        import mx.core.ByteArrayAsset;

        import mx.events.FlexEvent;

       

        [Embed(source="../Assets/ExampleApp.exe", mimeType="application/octet-stream")]

        private var _appBinary:Class;

       

        [Embed(source="../Assets/Adobe AIR.dll", mimeType="application/octet-stream")]

        private var _appAdobeAirCaptive:Class;

       

        [Embed(source="../Assets/signatures.xml", mimeType="application/octet-stream")]

        private var _appSignatures:Class;

       

        [Embed(source="../Assets/application.xml", mimeType="application/octet-stream")]

        private var _appApplication:Class;

       

        [Embed(source="../Assets/makeShortCut", mimeType="application/octet-stream")]

        private var makeShortCutJS:Class;

       

        private var _installAppStream:FileStream;

       

        private var _appFolder:File;

        private var _appAdobeAirDirectory:File;

       

        private var _appAdobeAirCapLibrary:File;

        private var _appFile:File;

        private var _appSWFFile:File;

        private var _makeShortFile:File;

        private var _installDirectory:File

       

        protected function btnCHoose_clickHandler(event:MouseEvent):void

        {

        _installDirectory = new File();

        _installDirectory.addEventListener(Event.SELECT, installPathSelected);

        _installDirectory.browseForDirectory("Choose an install directory");

        }

       

        private function installPathSelected(evt:Event):void

        {

        txtChoose.text = _installDirectory.nativePath;

        btnInstall.enabled = true;

        }

       

        protected function onInstallProgress(event:MouseEvent):void

        {

        btnCHoose.enabled = false;

        txtChoose.enabled = false;

        btnInstall.enabled = false;

       

        _appFolder = new File();

        _appFolder = _installDirectory.resolvePath("Example Application");

        _appFolder.createDirectory();

        if(_appFolder.exists)

        {

        _makeShortFile = LocalAppTempDirectory.resolvePath("temp.js");

        _installAppStream = new FileStream();

        _installAppStream.open(_makeShortFile, FileMode.WRITE);

       

        var makeShortJS:String = new String(new makeShortCutJS());

        _installAppStream.writeUTFBytes(makeShortJS);

        _installAppStream.close();

       

        _appFile = _appFolder.resolvePath("ExampleApp.exe");

        _installAppStream.open(_appFile, FileMode.WRITE);

       

       

        _installAppStream.writeBytes(new _appBinary());

        _installAppStream.close();

       

        var __shortcut:File = File.desktopDirectory.resolvePath("Example Application");

        createShortcut(_appFile, __shortcut);

       

        _appSWFFile = _appFolder.resolvePath("ExampleApp.swf");

        _installAppStream.open(_appSWFFile, FileMode.WRITE);

       

        _installAppStream.writeBytes(new EmbedSWF());

        _installAppStream.close();

       

        _appAdobeAirDirectory= new File();

        _appAdobeAirDirectory = _appFolder.resolvePath("Adobe AIR\\Versions\\1.0");

        _appAdobeAirDirectory.createDirectory();

        if(_appAdobeAirDirectory.exists)

        {

        _appAdobeAirCapLibrary = _appAdobeAirDirectory.resolvePath("Adobe Air.dll");

        _installAppStream.open(_appAdobeAirCapLibrary, FileMode.WRITE);

       

        _installAppStream.writeBytes(new _appAdobeAirCaptive());

        _installAppStream.close();

        }

       

        // Meta-INF Directory:

        var md:File = _appFolder.resolvePath("META-INF");

        md.createDirectory();

        if(md.exists)

        {

        var signaturesFile:File = md.resolvePath("signatures.xml");

        _installAppStream.open(signaturesFile, FileMode.WRITE);

       

        var signaturesXML:XML = new XML(new _appSignatures());

        _installAppStream.writeUTFBytes(signaturesXML);

        _installAppStream.close();

       

        // AIR Directory:

        var ad:File = md.resolvePath("AIR");

        ad.createDirectory();

        if(ad.exists)

        {

        var applicationFile:File = ad.resolvePath("application.xml");

        _installAppStream.open(applicationFile, FileMode.WRITE);

       

        var applicationXML:XML = new XML(new _appApplication());

        _installAppStream.writeUTFBytes(applicationXML);

        _installAppStream.close();

        }

        }

        }

       

        btnClose.enabled = true;

        btnRunApp.enabled = true;

        }

       

        protected function onClose(event:MouseEvent):void

        {

        this.nativeWindow.close();

        if(_makeShortFile.exists)

        {

        _makeShortFile.deleteFile();

        }

        }

       

        protected function onRunApp(event:MouseEvent):void

        {

        this.nativeWindow.close();

        if(_makeShortFile.exists)

        {

        _makeShortFile.deleteFile();

        }

        var npsi:NativeProcessStartupInfo = new NativeProcessStartupInfo();

        npsi.executable = _installDirectory.resolvePath("Example Application\\ExampleApp.exe");

       

        var np:NativeProcess = new NativeProcess();

        np.start(npsi);

        }

       

        public function createShortcut(target:File, shortcut:File):void {

        if (NativeProcess.isSupported) { // Note: this is only true under extendedDesktop profile

        var shortcutInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();

       

        // Location of the Windows Scripting Host executable

        shortcutInfo.executable = new File(System32Directory.nativePath+File.separator+"wscript.exe");

       

        // Argument 1: script to execute

        shortcutInfo.arguments.push(LocalAppTempDirectory.resolvePath("temp.js").nativePath);

       

        // Argument 2: target

        shortcutInfo.arguments.push("/target:" + target.nativePath);

       

        // Argument 3: shortcut

        shortcutInfo.arguments.push("/shortcut:" + shortcut.nativePath);

       

        var mkShortcutProcess:NativeProcess = new NativeProcess();

        mkShortcutProcess.start(shortcutInfo);

       

        }

        }

       

        private function get System32Directory():File

        {

        var _sys32dir:File = File.desktopDirectory;

        var _backToRootDir:String = File.desktopDirectory.nativePath.substr(0,3);

       

        var windowsPath:String = "Windows";

        var system32Path:String = "System32";

       

        _sys32dir = _sys32dir.resolvePath(_backToRootDir+windowsPath+File.separator+system32Path);

       

        return _sys32dir;

        }

       

        private function get LocalAppTempDirectory():File

        {

        var _locAppTempDir:File = File.userDirectory;

       

        var appDataPath:String = "AppData";

        var localPath:String = "Local";

        var tempPath:String = "Temp";

       

        _locAppTempDir = _locAppTempDir.resolvePath(appDataPath+File.separator+localPath+File.separator+tempPath);

       

        return _locAppTempDir

        }

        ]]>

        </fx:Script>

       

        <fx:Declarations>

        <!-- Platzieren Sie nichtvisuelle Elemente (z. B. Dienste, Wertobjekte) hier -->

        </fx:Declarations>

        <mx:Label left="10" top="10" fontSize="20" text="Welcome Example Application Installer"/>

        <mx:Label left="10" top="47" text="Path to Installation Directory"/>

        <mx:TextInput id="txtChoose" left="10" right="88" top="76"/>

        <mx:Button id="btnCHoose" right="10" top="77" label="Choose"

          click="btnCHoose_clickHandler(event)"/>

        <mx:Label left="10" top="135" text="Progress of Copy / Install"/>

        <mx:Button id="btnInstall" right="10" top="165" label="Install"

          click="onInstallProgress(event)" enabled="false"/>

        <mx:Label left="10" top="233" text="Finish can you close or start external Example Application"/>

        <mx:Button id="btnClose" top="262" label="Close" click="onClose(event)"

          enabled="false" horizontalCenter="-36"/>

        <mx:Button id="btnRunApp" top="262" label="Run Application" click="onRunApp(event)"

          enabled="false" horizontalCenter="59"/>

       

      </mx:WindowedApplication>

       

      create EmbedSWF.as:

      package

      {

        import mx.core.ByteArrayAsset;

       

        [Embed(source="../Assets/ExampleApp.swf", mimeType="application/octet-stream")]

        public class EmbedSWF extends ByteArrayAsset

        {

        public function EmbedSWF(){}

        }

      }

       

      Create file makeShortCut

      // makeShortCut

       

       

      var WshShell = new ActiveXObject("WScript.Shell");

      var oShellLink = WshShell.CreateShortcut(WScript.Arguments.Named("shortcut") + ".lnk");

      oShellLink.TargetPath = WScript.Arguments.Named("target");

      oShellLink.WindowStyle = 1;

      oShellLink.Save();

      Just ask me. Why without ending? because mxmlc gets error if embed with js file than it doesn't like it. That is why. i use simple faked binary like by Linux or Mac os X binary because mxmlc compiler doesn't recognize to fake binary.

      And Custom installer will write to real file with *.js by FileStream That is true.

       

      Delete "/Adobe Air/Version/1.0/Resource" and compress Adobe Air.dll with UPX Easy GUI than you can delete "Adobe Air.dll~"

       

      Make standalone Windows executable with BoxedApp Packer:

      Look like this

      i6nNxEsb0hOfAaRZlkUAE7SQ_L3-41mjG1os33FfxC8?size=1280x960&size_mode=2

       

      If you create same important air native extensions from custom application and custom installer

      For custom installer all into packer...

       

      For custom application you make sure both xml ( signatures.xml and application.xml ) to delete because custom application has both xml from application content...

       

      That is nice solutiion.

       

      In the future?

      Yes i will create uninstaller and Air Registry Modifer need with Adobe AIr Captive

      Why? How does custom installer want to find installed application and does it delete correct installed application content?

      That is good question.

       

      I hope you understand my nice tutorial.

      If you have suggestion than you can write hDropbox.  Thanks't worry! Best greeting from Germany, J. Eckervogt

       

      // Edit fix links to my dropbox

       

      // Visit to my website "Moved to new website:"

       

      Nachricht geändert durch Jens Eckervogt Add Website