다음과 같이 wscript.shell이라는 com을 사용하면 exe를 호출할 수 있다. 리턴값을 받기 위해서는 ret=wshell.run(cmd, 0, true)할 때 마지막 parameter를 true로 주어야 한다. 리턴이 올때까지 기다린다는 뜻이다.
만약 호출하는 exe가 윈도우 프로그램이거나(윈도우 메세지 루프를 가져서 프로그램이 끝나지 않음) 또는 파일을 쓰는 (FILE* 등)프로그램이면 리턴이 되지 않고 멈춰버린다.
'절대패스로 지정해야함
exe = "C:\testweb\test.exe"
cmd = exe + "arg1 arg2 ..."
'객체 생성
dim wshell
set wshell = server.createobject("wscript.shell")
response.write cmd&"<br>"
'객체 생성 실패시 에러
if wshell is nothing then
response.write "S201:WScript.Shell Initialization Failure"
end if
'외부 프로그램 실행후 리턴값 받아서 화면에 출력
ret=wshell.run(cmd, 0, true)
response.write ret
'객체 소멸
set wshell=nothing
