Skip to main content
Inspiring
July 5, 2018
Answered

Restarting an AIR desktop application

  • July 5, 2018
  • 1 reply
  • 1392 views

Hello,

I need a DESKTOP AIR application (captive runtime bundle) to be able to restart itself after an update process.

The method involving productManager.launch doesn't work because <allowBrowserInvocation></allowBrowserInvocation> cannot be set to true for an application packaged with the captive runtime option :

Does anyone has a solution to this problem ?

Thanks.

Vincent.

This topic has been closed for replies.
Correct answer After24

Hello el111,

Thank you.

Found a solution that works on both mac and win based on native script too.

public  function restartApplication():void
{
   var applicationDescriptor:XML = NativeApplication.nativeApplication.applicationDescriptor;
   var xmlns:Namespace = new Namespace(applicationDescriptor.namespace());
   var applicationName:String = applicationDescriptor.xmlns::filename;
   var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
   var nativeProcess:NativeProcess = new NativeProcess();
   var applicationExecutable:File;

   if (Capabilities.os.indexOf("Win") > -1)
   {
        applicationExecutable = new File(File.applicationDirectory.nativePath + "/" + applicationName + ".exe");

   }else{
 
        applicationExecutable = new File(File.applicationDirectory.nativePath.replace("Resources", "MacOS/" + applicationName));
   }

   nativeProcessStartupInfo.executable = applicationExecutable;
   nativeProcess.start(nativeProcessStartupInfo);
   NativeApplication.nativeApplication.exit();
}

1 reply

Legend
July 8, 2018

You can try running a bat script using NativeProcess

https://forum.starling-framework.org/topic/restart-standalone-application-on-desktop-windows

or you can use this ANE

which has a method called restartApp()

GitHub - tuarua/WindowsHelperANE: a set of methods for Adobe AIR for Windows

After24AuthorCorrect answer
Inspiring
July 9, 2018

Hello el111,

Thank you.

Found a solution that works on both mac and win based on native script too.

public  function restartApplication():void
{
   var applicationDescriptor:XML = NativeApplication.nativeApplication.applicationDescriptor;
   var xmlns:Namespace = new Namespace(applicationDescriptor.namespace());
   var applicationName:String = applicationDescriptor.xmlns::filename;
   var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
   var nativeProcess:NativeProcess = new NativeProcess();
   var applicationExecutable:File;

   if (Capabilities.os.indexOf("Win") > -1)
   {
        applicationExecutable = new File(File.applicationDirectory.nativePath + "/" + applicationName + ".exe");

   }else{
 
        applicationExecutable = new File(File.applicationDirectory.nativePath.replace("Resources", "MacOS/" + applicationName));
   }

   nativeProcessStartupInfo.executable = applicationExecutable;
   nativeProcess.start(nativeProcessStartupInfo);
   NativeApplication.nativeApplication.exit();
}