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

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

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.