Hello sirs & ladies,
I have biggest problem with Adobe Air and Windows Binaries.
I have created simple "HomeDrive():File" for C:\ or D:\ If you have installed Windows OS on current drive-letter
And i have created same directories for Windows and System32 folders..Code:public static function get HomeDrive():File { var _drives:Array = File.getRootDirectories() for ( var i:int = 0; i < _drives.length; i++) { if(_drives[0].exists) { _homeDrive = _drives[0] } } return _homeDrive; }
I have built simple RegistryModify by ya110 but i don't need to use py2exe-binary.Code:public static function get WindowsDirectory():File { if (osName.indexOf("win") > -1) { _winDir = FileUtils.HomeDrive.resolvePath(WINDOWS_PATH); } return _winDir; } public static function get System32Directory():File { if (osName.indexOf("win") > -1) { _sys32 = FileUtils.WindowsDirectory.resolvePath(SYSTEM32_PATH); } return _sys32; }
I use simple native path to reg.exe from C:\Windows\System32\reg.exe
But my code is not finish.
Than i have created Flex Project. I am tried but i have correct application name of exe.Code:package net.sourceskyboxer.utils { import flash.desktop.NativeProcess; import flash.desktop.NativeProcessStartupInfo; import flash.events.Event; import flash.events.EventDispatcher; import flash.events.NativeProcessExitEvent; import flash.events.ProgressEvent; public class RegModifer extends EventDispatcher { private var _np:NativeProcess; private var _npi:NativeProcessStartupInfo; private var _args:Vector.<String>; private var _exePath:String; public var _output:String; public function RegModifer() { _exePath = FileUtils.System32Directory.resolvePath("reg.exe").nativePath; } public function addKey(_rootKey:String, _path:String, _key:String, _value:String):void { _args = new Vector.<String>; _args.push(' add \"'+_rootKey+_path+'\" /v \"'+_key+'\" /t REG_SZ /d \"'+_value+'\"'); regProgress(); } private function regProgress():void { _npi = new NativeProcessStartupInfo(); _npi.executable = FileUtils.System32Directory.resolvePath("reg.exe"); _npi.arguments = _args; _np = new NativeProcess(); _np.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData); _np.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, onErrorData); _np.addEventListener(NativeProcessExitEvent.EXIT, onExit); _np.start(_npi) } public function get output():String { return _output; } private function onOutputData(e:ProgressEvent):void { _output = String(_np.standardOutput.readUTFBytes(_np.standardOutput.bytesAvailable)); dispatchEvent(new Event("OutputData")); } private function onErrorData(e:ProgressEvent):void { _output = String(_np.standardError.readUTFBytes(_np.standardError.bytesAvailable)); dispatchEvent(new Event("ErrorData")); } private function onExit(e:NativeProcessExitEvent):void { _np.removeEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData); _np.removeEventListener(ProgressEvent.STANDARD_ERROR_DATA, onErrorData); _np.removeEventListener(NativeProcessExitEvent.EXIT, onExit); _npi = null; _np = null; _args = null; dispatchEvent(new Event(Event.COMPLETE)); } } }
Why does it happen if it shows "Error: Wrong argements/options" What does it mean? I have written current reg add "HKCU\<-Path-> /v <-Key-> /t REG_SZ /d <- Value ->
I don't understand why does Adobe Air go wrong?
How do i fix? Maybe " or ' ??
My code:
P.S: Please delete / ignone same important library because i don't give it.Code:<?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" usePreloader="false" creationComplete="onCreationCompleteHandler(event)"> <fx:Script> <![CDATA[ import flash.net.dns.AAAARecord; import flash.sampler.NewObjectSample; import mx.core.Window; import mx.events.FlexEvent; import net.sourceskyboxer.utils.CommandModifer; import net.sourceskyboxer.utils.FileUtils; import net.sourceskyboxer.utils.RegModifer; import net.sourceskyboxer.utils.Rundll32Modifer; private var installPathDir:File; private var cm:CommandModifer; private var rm:RegModifer; private var appPath:String = File.applicationDirectory.nativePath+File.separator+"fxCommand.exe"; protected function onCreationCompleteHandler(event:FlexEvent):void { testdrive.text = FileUtils.HomeDrive.nativePath; /** * Call from kernel32.dll, peep(); */ var rundll:Rundll32Modifer = new Rundll32Modifer(); } private function onError(e:Event):void { cmdMessage.text = cm._output; } private function onReadTerminal(e:Event):void { cm.removeEventListener("OutputData", onReadTerminal); cmdMessage.text = cm._output; } protected function chooseHandler(event:MouseEvent):void { installPathDir = new File(); installPathDir.browseForDirectory("Choose to installing application"); installPathDir.addEventListener(Event.SELECT, onChooseDir); } private function onChooseDir(evt:Event):void { testdrive.text = installPathDir.nativePath; } protected function RunAsHandler(event:MouseEvent):void { rm = new RegModifer(); rm.addKey("HKCU","\\Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers",appPath,"RUNASADMIN"); rm.addEventListener("OutputData", onWriteComplete); rm.addEventListener("ErrorData", onRegError); } private function onWriteComplete(e:Event):void { rm.removeEventListener("OutputData", onWriteComplete); cmdMessage.text = rm._output; } private function onRegError(e:Event):void { cmdMessage.text = rm._output; } ]]> </fx:Script> <fx:Declarations> <!-- Platzieren Sie nichtvisuelle Elemente (z.*B. Dienste, Wertobjekte) hier --> </fx:Declarations> <mx:TextArea left="10" right="10" top="10" bottom="40" id="cmdMessage"/> <mx:TextInput id="testdrive" left="10" right="172" bottom="10"/> <mx:Button right="10" bottom="10" label="Runas" click="RunAsHandler(event)"/> <mx:Button right="85" bottom="10" label="Choose..." click="chooseHandler(event)"/> </mx:WindowedApplication>
And i compile into Adobe Air Captive Runtime than it shows error:
I try with terminal of WIndows: cmd:
It is successful but Adobe Air is stupid because it can not call current? How do i fix?
You know like Languages.. Sorry German Language i am using Windows OS
Can you help me ?





Reply With Quote
