본문 바로가기

공부방/Flex

[Flex] Flex에서 Wake On Lan Command Line

먼저 Wake On Lan에 대한 Command Line에 대한 정보 및 자료는  http://www.depicus.com/wake-on-lan/wake-on-lan-cmd.aspx 에서 참고 하였습니다.
 

해당 자료는 Free 라는 멘트가 넘흐 와 닫는다 ㅎㅎ

실제 Flex에서 해당 작업을 처리 하기 위해서는 Flex NativeProcess를 사용 해야 한다.




 
//wakeonlan 실행
public function WakeOnLan(event:MouseEvent) : void {
	if ( NativeProcess.isSupported ) {   //  옵션에서 extendedDesktop 을 해줘야 사용할수 있다.
		//get the directory 
		var wakeOnLan:NativeProcess;
		var file:File = File.applicationDirectory;
		file = file.resolvePath("WakeOnLan");
		// point to the file 
		file = file.resolvePath("WolCmd.exe"); 
		//define process startup information 
		var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo(); 
		nativeProcessStartupInfo.workingDirectory =  new File(File.applicationDirectory.nativePath + File.separator + "WakeOnLan");
		var args:Vector. = new Vector.(); 
		
		
		var macaddress:String =  "001122334455";  //Macaddress
		var ip:String = "192.168.0.1";  //Ip
		var subnetMask:String = "255.255.255.0";  //SubNetMask
		var port:String = "8080"; // Port
		
		args.push(macaddress);
		
		nativeProcessStartupInfo.arguments = args;
		nativeProcessStartupInfo.executable = file;
		
		wakeOnLan = new NativeProcess(); 
		wakeOnLan.addEventListener( NativeProcessExitEvent.EXIT, onExit); 
		try { 
			wakeOnLan.start( nativeProcessStartupInfo ); 
		} catch ( error : IllegalOperationError ) { 
			Alert.show( "Illegal Operation: " + error.toString(),"확인",4,this); 
		} catch ( error : ArgumentError ) { 
			Alert.show( "Argument Error: " + error.toString(),"확인",4,this); 
		} catch ( error : Error ) { 
			Alert.show( "Error: " + error.toString(),"확인",4,this); 
		}
	} else {
		Alert.show( "네이티브 프로세스 지원안됨.","확인",4,this);
	}
}


public function onExit(e:Event):void {
	trace("WakeonLan 수행");
}
Flex 에서 해당 기능을 구현한 소스~