1 Reply Latest reply on Apr 22, 2011 3:56 AM by Jens Eckervogt

    Runas and Adobe Application Air 2.x?

    Jens Eckervogt Level 1

      Hello dear people,


      I have been found this trick of RUNASADMIN or EVELATEDPROCESS this url:  http://www.sevenforums.com/tutorials/316-compatibility-mode.html


      Look Step: "OPTION THREE" and Manually in Registry Editor



      I think sure becasue we are suing with Adobe Application AIr 2.x via Administrative rights for Windows Vista and 7....


      Like this Code: But i am not finish this code. I am not sure when you are sure for xml and regkey files?



           Runas to Application Air
           Support for Windows Vista and Windows 7
           import flash.desktop.NativeProcessStartupInfo;
           import flash.filesystem.File;
           import flash.filesystem.FileStream;
           public class StartRunAs
                public var RunasXML:File = new File(var xml:XML = <runas>runasCall()</runas>);
                public var smDir_Runas:File = File.applicationStorageDirectory;
                public var runas_reg_key:File = File.applicationStorageDirectory.resolvePath("runas.reg");
                public function StartRunAs():void
                     // Copy from ApplicationDirectory
                          function runasCall():void
                                    function runas_Addreg():void
                                         // Start regedit with runas.reg
                                         var regeditApp:NativeProcessStartupInfo = new NativeProcessStartupInfo("C:\\Windows\\regedit.exe");
                                         regeditApp.arguments = runas_reg_key;
                                         // Delete startfiles - if you are assigned by UAC readly.
                                    // Write reg file:
                                    var runas_reg_key_Stream:FileStream = new FileStream();
                                         "Windows Registry Editor Version 5.00" +
                                         "" +
                                         '"' + File.applicationDirectory() + 'myapp.exe"' + '="RUNASADMIN"'
                                    // Execute to regedit add reg file 
                protected function SkipInit():void
                     // Now Your application with adminstrative rights 



      If your runas.reg should see a result: Like this:


      Windows Registry Editor Version 5.00
      [HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
      "C:\\Program Files (x86)\\MyApp Air\\Myapp.exe"="RUNASADMIN"


      Than Adobe Application Air calls NativeProcessStartInfo with "Regedit.exe runas.reg" and it will to change in administrative mode with Application Air 2.x.

      Than you can close Application Air and you click Shutcut from Desktop. What does it happen? Now Application Air starts with administrative privatages and you prompt "Yes" and Application Air loads and can rewrite in the directory C:\Program Files x(86)\MyApp\


      Did you think sure? That is a nice trick once UAC with read/write mode of Application Air for example:

      Plugins and templates will to copy in ApplicationDirectory Example: C:\Program Files x(86)\\MyApp\plugins or C:\Program Files x(86)\\MyApp\templates


      That is a good suggestion of my access rewriting! Do not worry , dear Windows Users!!!!


      I have been tired nice FileStream with process


      I hope you because you can improve or add suggestions We can work together


      Thanks best regards, SnakeMedia


      That is an example for assignned regkey once Adobe Application Air to adminstrative Application Air like any programs CCleaner or TuneUp Utilities 2011...

        • 1. Re: Runas and Adobe Application Air 2.x?
          Jens Eckervogt Level 1

          Hello peoples,


          i have been fixed this problem.


          But it show crazy because Adobe Air write worng word : [object file]. I can not try this problem


          I have been writen our code like this.

          AirAdmin.mxml: for Flex 3.5 with Air SDK 2.x


          <?xml version="1.0" encoding="utf-8"?>
          <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init(event)">
                         import mx.events.FlexEvent;
                         protected function init(event:FlexEvent):void
                              // Center main AIR app window on the screen
                              nativeWindow.x = (Capabilities.screenResolutionX - nativeWindow.width) / 2;
                              nativeWindow.y = (Capabilities.screenResolutionY - nativeWindow.height) / 2;
                              // Load regFile and cmdFile
                         private var airAdminFile:String = File.applicationDirectory + "AirAdmin.exe";
                         private var regeditFile:File = new File("C:\\Windows\\regedit.exe");
                         private var regFile:File = new File;
                         private var cmdFile:File = new File;
                         private var cmdAppFile:File = new File("C:\\Windows\\System32\\cmd.exe");
                         protected function getRegFile():void
                              // regfile
                              regFile = File.documentsDirectory.resolvePath("AirAdmin.reg");
                              var regFileStream:FileStream = new FileStream;
                              var regFileStructur:String = 'Windows Registry Editor Version 5.00';
                              regFileStructur += File.lineEnding;
                              regFileStructur += '[HKEY_CURRENT_USER\\Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers]' + File.lineEnding;
                              regFileStructur += '"' + airAdminFile + '"="RUNASADMIN"' + File.lineEnding;
                              cmdFile = File.documentsDirectory.resolvePath("AirAdmin.cmd");
                              var cmdFileStream:FileStream = new FileStream;
                              var cmdFileContent:String = regeditFile + '"' +regFile + '"' + File.lineEnding;
                              if(regFile.exists, cmdFile.exists)
                                   regFileStream.open(regFile, FileMode.READ);
                                   regFileStructur = String(regFileStream.readUTFBytes(regFileStream.bytesAvailable));
                                   cmdFileStream.open(cmdFile, FileMode.READ);
                                   cmdFileContent = String(cmdFileStream.readUTFBytes(cmdFileStream.bytesAvailable));
                                   regFileStream.open(regFile, FileMode.WRITE);
                                   cmdFileStream.open(cmdFile, FileMode.WRITE);
                         // NativeProcess
                         private var StartProcess:NativeProcess = new NativeProcess;
                         private var args:Vector.<String> = new Vector.<String>;
                         protected function openShell():void
                              var StartUpInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo;
                              StartUpInfo.executable = cmdAppFile;
                              StartUpInfo.arguments = args;
                                   // Your mode is as administrative right
                                   // It is not an administrative right mode!
               <mx:Label id="mylab" horizontalCenter="0" verticalCenter="0"/>



          Nothing has errors. Work fine...


          But 2 outputs for AirAdmin.reg and AirAdmin.cmd have worng words [object file].

          It has problem of writing with current directory. How do i fix path to text

          For Example:

          var AppFile:File = File.applicationDirectory.resolvedPath("App.exe")


          and i put in writing mode for regedit...

          Output should to show this:

          C:\\Program Fils (x86)\\App\\App.exe <- current result like sometime writing function to text mode


          But i have problem of writing mode - if i put in path and directory to text mode.

          Worng words:

          [object file]App.exe <- What is it crazy?


          2 worng words in 2 files ( reg and cmd )



          Windows Registry Editor Version 5.00
          [HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
          "[object File]AirAdmin.exe"="RUNASADMIN"



          and AirAdmin.cmd:


          @echo off@echo[object File]"[object File]"



          I do not understand because Air 2.6 has problem of writing path to text mode..


          Like this for example:

          File.applicationDirectory.resolvedPath("MyExampleApp.exe") to "C:\\Program Files (x86)\\MyExampleApp\\MyExampleApp.exe"


          A result will to show current path to executable in the reg file:

          "C:\\Program Files (x86)\\MyExampleApp\\MyExampleApp.exe"="RUNASADMIN"


          Thanks for advanced problem . I want to assign Application Air into Administrative Application Air


          I hope you because you think sure because i want to try Application Air to Administrative Mode


          Thanks for reply