Reverse Connection 을 이용해 원격으로 접속할 때 계속 cmd 창이 떴다 사라지는 현상을 없앨 방법이 없을까요?

ststsa의 이미지

직장이 사설IP를 사용하는 관계로 외부에서 원격으로 접속이 불가능했습니다. ( R-support 나 천리안 등의 외부망을 사용한 유료 서비스가 아닌 한... )

그러다 이래 링크를 보고 고맙게도 WinVNC 의 Reverse Connection 기능을 통해 외부에서 접속하는 것이 가능해졌습니다.

https://kldp.org/node/26821

그런데 문제는 접속 체크를 하는 시간마다(아래 스크립트에서는 10초) 화면에 잠깐이지만 cmd 실행 창이 떴다가 사라집니다.

이것이 처음에는 별 개 아니다 생각했었는데... 글을 쓸 때도 화면이 끊기고 파워포인트로 프레젠테이션을 할 때도 전체화면이 닫히는 등 문제가 많더라구요. T.T

혹시 아래 스크립트 보시고 화면에 CMD 창이 뜨는 문제를 해결할 방법이 없는 지 궁금해 질문드립니다.

<스크립트 전문>

'접속할 ip가 있는 페이지의 URL
url="http://abc.org/vnc.txt"
'체크할 초 간격
delay=10
 
Set http = CreateObject("WinHttp.WinHttprequest.5.1")
Set sh = CreateObject("WScript.Shell")
 
Do While True
    target = getURL(url)
 
 
 
   Set cmd = sh.exec("c:\windows\system32\netstat -an")
   netresult = cmd.StdOut.ReadAll
   Do While cmd.Status=0
       WScript.Sleep 50
   Loop
 
   Set cmd = Nothing
   If  InStr(netresult, target&":5500") Then
 
   Else
       Set cmd = sh.exec ("C:\Program Files\uvnc bvba\UltraVNC\winvnc -connect " & target )
   			Do While cmd.Status=0
       	WScript.Sleep 50
   			Loop
   			Set cmd = Nothing
        WScript.Sleep 30*1000
   End If
 
 
    WScript.Sleep delay*1000
Loop
 
Function getURL(url)
 
    Dim re, matches
 
    http.Open "GET", url, False
    http.Send
    getURL = http.ResponseText
    Set re = New RegExp
    re.Pattern = "([\w\.]+)"
    Set matches = re.Execute(getURL)
    getURL = matches.Item(0)
 
End Function

pynoos의 이미지

VBScript아닌 JScript 이긴 하지만..

http://smartbear.com/forums/f74/t97027/wscript-shell-without-dos-screen/

이 글로부터힌트를 얻는 건 어떨까요?

pynoos의 이미지

ststsa의 이미지

그런데 제가 프로그래밍을 하는 것도 아니고 어쩌다 물어물어 이곳까지 온 것이라
솔직히 알려주신 링크를 보고 어떻게 해야 하는지... 감도 못 잡겠습니다. ^^;;

좀 더 참조할 것이 없을까요?

pynoos의 이미지

sh.exec("c:\windows\system32\netstat -an")

이 구문을

sh.run("c:\windows\system32\netstat -an",0,True)

이렇게 바꾸는것 아닐까요?

ststsa의 이미지

알려주신대로 바꿔보았는데요.

그랬더니 오류가 나면서 정상적으로 실행되지 않습니다. ^^;;

아래는 바꾸고 나서의 내용이구요. 말씀하신 sh.run 부분에서 오류가 나네요.

------------------------------

'접속할 ip가 있는 페이지의 URL
url="http:/주소/vnc.txt"
'체크할 초 간격
delay=10

Set http = CreateObject("WinHttp.WinHttprequest.5.1")
Set sh = wscript.createobject("WScript.Shell")

Do While True
target = getURL(url)

Set cmd = sh.run("c:\windows\system32\netstat -an"),0,true
netresult = cmd.StdOut.ReadAll
Do While cmd.Status=0
WScript.Sleep 50
Loop

Set cmd = Nothing
If InStr(netresult, target&":5500") Then

Else
Set cmd = sh.exec ("C:\Program Files\uvnc bvba\UltraVNC\winvnc -connect " & target )
Do While cmd.Status=0
WScript.Sleep 50
Loop
Set cmd = Nothing
WScript.Sleep 30*1000
End If

WScript.Sleep delay*1000
Loop

Function getURL(url)

Dim re, matches

http.Open "GET", url, False
http.Send
getURL = http.ResponseText
Set re = New RegExp
re.Pattern = "([\w\.]+)"
Set matches = re.Execute(getURL)
getURL = matches.Item(0)

End Function

-----------------------------------