Jump to content

Windows Compatibility Mode


Recommended Posts

I am working on a remote connection program that creates an SSH tunnel to a remote WinPC, and then tunnels an RDP connection through SSH. The problem I'm having is that mstsc.exe doesn't allow connections to 'localhost' or any port (even if forwarded through ssh). I have to set compatibility mode to Win 98/Me (or something like that).

Any help would be greatly appreciated!

(The below code sets an ssh connection to port 5000, which is port-forwarded by my router. OpenSSH is used for this program).

Opt("WinTitleMatchMode", 2)
Dim $pass = ""
While $pass = ""
$pass = InputBox("Remote Connection", "Please enter your account password", "", "")
WEnd
BlockInput(1)

;Start SSH Connection and send password
$ssh = Run("ssh.exe -c blowfish -N -L 4000:localhost:3389 Susan@someplace.com -p 5000")
Sleep("2000")
Send($pass)
Send("{ENTER}")
Sleep("5000")

;Start Remote Desktop Connection
$rdp = Run(@ScriptDir & "\mstsc.exe /v:localhost:4000 /console /f")
WinWait("localhost:4000 - Remote Desktop")
WinSetState("ssh.exe", "", @SW_HIDE)
Sleep("700")
Send($pass)
Send("{ENTER}")
$pass = ""
BlockInput(0)

;Waits until RDP is closed, and then prompts to close connection else respawns RDP
$continue = 1
While $continue = 1
If ProcessExists($rdp) = 0 Then
    $quit = MsgBox(4, "Remote Connection", "Do you want to disconnect from the remote system?", 5)
    If $quit = 7 Then
        $rdp = RunWait(@ScriptDir & "\mstsc.exe /v:localhost:4000 /console /f")
        $quit = 0
    Else
        $continue = 0
    EndIf
EndIf
WEnd
ProcessClose($ssh)

Writing AutoIt scripts since

_DateAdd("d", -2, _NowCalcDate())
Link to comment
Share on other sites

1) Can you use its IP not localhost?

I just tried, couldn't get it to work

2) What about using VPN? instead of RDP thru SSH

I think this would be your best bet

3) Not sure how windows handles the SSH connection but you can't have multiple people logged onto (and not have people locked out) XP, so you might get weird behavior RDPing to yourself

Edited by Ejoc
Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs
Link to comment
Share on other sites

It's not RDPing to myself. I have SSH redirect a port on this machine to a port located on the other machine, after passing through the VPN tunnel, much like VPN, however there is no network connection to the remote machine. The localhost:4000 is the port that is forwarded to the remote machine.

Windows just doesn't like the fact that you don't necessarily connect to localhost when you use localhost in the address box...

Writing AutoIt scripts since

_DateAdd("d", -2, _NowCalcDate())
Link to comment
Share on other sites

Windows sees that as localhost as well. I found a CMD level command that *hopefully* does it for me.

set __COMPAT_LAYER=Win98 ;;Sets Compatibility Mode to Windows 98

;Run Command

set __COMPAT_LAYER= ;;Removes Compatibility Mode

Writing AutoIt scripts since

_DateAdd("d", -2, _NowCalcDate())
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...