AND

출처 : http://nazelm.egloos.com/938351

WshShell.Run

Dim WshShell : Set WshShell = WScript.CreateObject("WScript.Shell")
intError = WshShell.Run (strCommand [, intWindowStyle] [, bWaitOnReturn])
WshShell.Run strCommand [, intWindowStyle] [, bWaitOnReturn]
' cf, 반환값 없이 단독 실행시에는 괄호로 묶지 않는다.

- intError : Error code (실행결과로 해당 명령줄에 의해 실행된 프로그램이 반환하는 정수값)
- strCommand : 명령줄 문장
- intWindowStyle : Optional. ([]로 묶인 항목은 전부 선택항목)
0    Hides the window and activates another window.
1    Activates and displays a window.
     If the window is minimized or maximized, the system restores it to its original size and position.
     An application should specify this flag when displaying the window for the first time.
2   Activates the window and displays it as a minimized window. 
3   Activates the window and displays it as a maximized window. 
4   Displays a window in its most recent size and position.
     The active window remains active.
5   Activates the window and displays it in its current size and position.
6   Minimizes the specified window and activates the next top-level window in the Z order.
7   Displays the window as a minimized window. The active window remains active.
8   Displays the window in its current state. The active window remains active.
9   Activates and displays the window.
    If the window is minimized or maximized, the system restores it to its original size and position.
     An application should specify this flag when restoring a minimized window.
10  Sets the show-state based on the state of the program that started the application.

- bWaitOnReturn : Optional. Boolean Value(True / False, default is False)
명령줄에 의한 프로그램 실행이 완료될 때까지 기다릴 것인지 여부.
기본값은 False 이며, 생략시 해당 명령줄에 의한 프로그램 실행 여부와 상관없이
자동으로 0을 반환하고, 다음 스크립트가 계속 진행된다. (cf, 에러코드가 아닌 0을 반환)
cf, SendKey 메소드 등과 같이 쓸 때 True(기다림) 옵션을 적용해도 다음 스크립트가
    계속 진행된다. (SendKeys 에서의 순차실행 트릭 - 아래 Do While문 참조..)

WshShell.Run "%windir%\notepad" & WScript.ScriptFullName
intError = WshShell.Run("notepad " & WScript.ScriptFullName, 1, True)

Dim WshShell : Set WshShell = WScript.CreateObject ("WScript.Shell")
Dim oExec : Set oExec = WshShell.Exec("calc")

' 순차 실행 트릭 (Do While 문으로 Status 가 0 일 경우,
' = 프로그램 실행중 일 경우 Sleep으로 계속 창이 떠 있게 한다.)
Do While oExec.Status = 0
     WScript.Sleep 100
Loop

WScript.Echo oExec.Status
'  Status =  0  : The job is still running.
'  Status =  1  : The job has completed.


* 비교 : Run 과 Exec
'=> Run 은 실행만 하지만, Exec는 실행과 동시에 개체(object)를 생성한다.
'    따라서 Exec를 통한 실행은 생성된 개체를 이용한 후속 작업이 용이하다.

Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
TempName = FSO.GetTempName
TempFile = TempName

WshShell.Run "cmd /c ping -n 3 -w 1000 157.59.0.1 >" & TempFile, 0, True
Set TextFile = FSO.OpenTextFile(TempFile, 1)
Do While TextFile.AtEndOfStream <> True
    strText = TextFile.ReadLine
    If Instr(strText, "Reply") > 0 Then
        Wscript.Echo "Reply received."
        Exit Do
    End If
Loop

TextFile.Close
FSO.DeleteFile(TempFile)


' 아래는 동일한 결과는 가지는 Exec 를 통한 실행이다.
' 실행을 통해 반환되는 StdOut 에 접근하기위해 임시파일 만들고 할 필요가 없다.

Dim WshShell : Set WshShell = WScript.CreateObject("WScript.Shell")
Dim ExecObject : Set ExecObject = WshShell.Exec ("cmd /c ping -n 3 -w 1000 157.59.0.1")
Do While Not ExecObject.StdOut.AtEndOfStream
    strText = ExecObject.StdOut.ReadLine
Loop

AND

출처: http://deguls.tistory.com/

FLEX <-> Javascript 통신
보안샌드박스에러가 날땐 Object 태그에 allowScriptAcess 부분 설정을 변경해야 합니다.

HTML : sample.html
<script>
function SendToSWF(value){
    document.getElementById("externalcallswf").receive(value);
}
function Receive(value){
    document.getElementById("txtData").value = value;
}
</script>
<object id="externalcallswf" classid="clsid:.................>
<param name="무비경로" />
<param name="allowScriptAcess" value="allways" />
..
..
</object>


 

Flex : externalcalls.MXML
<?xml .... ?>
<mx:Application createComplete="initApp()" .....>
<mx:Script>
   <![CDATA[
    import flash.external.ExternalInterface;
    import flash.events.*;
    import mx.controls.Alert;

    private function initApp():void
    {
        if(ExternalInterface.available)
        {
             ExternalInterface.addCallback("receive", receive);
        }else{
            mx.controls.Alert.show("통신 불가..");
        }
    }

    private function receive(value:String):void{
            mx.controls.Alert.show(value);
    }

    private function sendToHTML(value:String):void{
           if(ExternalInterface.available)
           {
               ExternalInterface.call("Receive", value);
           }else{
               mx.controls.Alert.show("통신 불가..");
           }
    }
    ]]>
</mx:Script>


FLEX <-> C# (flex 부분은 상단과 동일 합니다.)
C# 어플리케이션에서 Flex나 Flash로 데이터를 보내거나 받으려면 아래와 같이 XML문서를 사용해야 합니다.
<invoke name="application name">
    <arguments>
        <string>문자열</string>
        <number>숫자형</number>
         ......
    </arguments>
</invoke>

Flash Object 참조방법 (단 플래시 플레이어가 Debug 버젼일 경우 윈폼 디자이너에 로드되지 않습니다.)
1. 참조 -> com -> Shockwave Flash 참조 추가
2. 도구상자 마우스 오른쪽 버튼 항목 선택 -> com 구성요소 -> Shockwave Flash 체크

C# Application
...
// 인보크 메세지 수신 이벤트 등록
this.axFlash.FlashCall += new AxShockwaveFlashObjects._IShockwaveFlashEvents_FlashCallEventHandler(this.axFlash_FlashCall);
...

// SWF로 데이터 전달
private void SendToSWF(string strData, int intData){
    string invokeXmlData = "<invoke name=\"TansInformation\"><arguments>";
    invokeXmlData += "<string>" + strData + "</string>";
    invokeXmlData += "<number>" + intData.ToString() + "</number>";
    invokeXmlData += "</arguments></invoke>";
    try
    {
         this.axFlash.CallFunction(invokeXmlData);          
     }catch{
         MessageBox.Show("인보크 메세지 전달 실패 \r\n\r\n" + invokeXmlData);
    }
}

// 플래시 전송 이벤트 수신
private void axFlash_FlashCall(object sender, AxShockwaveFlashObjects._IShockwaveFlashEvents_FlashCallEvent e)
{
    // xml 데이터
    XmlDocument XmlDoc = new XmlDocument();
    XmlDoc.LoadXml(e.request);
    XmlNodeList ArgumentList = XmlDoc.GetElementsByTagName("arguments");
   
    string XmlArguments = "";
    for(int i = 0;i<ArgumentList.Count;i++)
    {
        XmlArguments += ArgumentList[i].InnerText + Environment.NewLine;
    }
    MessageBox.Show(XmlArguments);
}
AND