Jump to content
Sign in to follow this  
JRSmile

nearly seemless rdp

Recommended Posts

JRSmile

hi folks, created some neat stuff here:

$server = "server"
$domain = "domain"
$user = "Administrator"
$password = "secretunknownpass123"

#include <GUIConstants.au3>
Const $WS_EX_NOPARENTNOTIFY = 0x4
Const $WS_EX_NOINHERITLAYOUT = 0x100000
$hUIContainerClassStyle = BitOR($WS_CHILD, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS, $WS_VISIBLE) ; 0x56000000
$hUIContainerClassStyleEx = BitOR($WS_EX_NOINHERITLAYOUT, $WS_EX_NOPARENTNOTIFY) ; 0x00100004
$hUIMainClassStyle = BitOR($WS_CHILD, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS, $WS_SYSMENU, $WS_VISIBLE) ; 0x56080000
$hUIMainClassStyleEx = 0x0
$hATLStyle = BitOR($WS_CHILD, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS, $WS_VISIBLE) ; 0x56000000
$hATLStyleEx = 0x0
$guiStyle = BitOR($WS_BORDER, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS, $WS_DLGFRAME, $WS_VISIBLE) ; 0x17CF0100
$guiStyleEx = $WS_EX_WINDOWEDGE ; 0x00000100

$width = 660
$height = 300
$oRDP = ObjCreate("MsTscAx.MsTscAx")
$GUI = GUICreate("RemoteCMD - " & $server, $width, $height, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
_SetStyle($gui,$guiStyle,$guiStyleEx)
$GUIActiveX = GUICtrlCreateObj($oRDP, 0, 0, $width, $height)
GUISetState(@SW_HIDE)


; connect to the server. if this is not done first, the child controls are not rendered.
; which is a problem, because we have to change their styles to prevent clipping
$oRDP.Server = $server
$oRDP.Domain = $domain
$oRDP.UserName = $user
$oRDP.AdvancedSettings2.ClearTextPassword = $password
$oRDP.FullScreen = false
$oRDP.AdvancedSettings2.RedirectDrives = True
$oRDP.AdvancedSettings2.RedirectPrinters = False
$oRDP.AdvancedSettings2.RedirectPorts = False
$oRDP.AdvancedSettings2.RedirectSmartCards = False
;$oRDP.AdvancedSettings2.ConnectToServerConsole = True
$oRDP.SecuredSettings.StartProgram = "cmd.exe" ; putty.exe
$oRDP.StartConnected = True
$oRDP.Connect()

; Determine the class name of the ATL control - it seems to be random from system to system
Opt("WinTitleMatchMode", 4)     ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("WinSearchChildren", 1)     ;0=no, 1=search children also
$sATLClass = ""
$aClasses = StringSplit(WinGetClassList($GUI,""),@LF)
For $i = 1 To $aClasses[0]
    If StringLeft($aClasses[$i],4) = "ATL:" Then
        $sATLClass = $aClasses[$i]
        ExitLoop
    EndIf
Next

; get the handles to the controls that must have their styles modified
$hUIContainerClass = ControlGetHandle($GUI, "", "[CLASS:UIContainerClass]")
$hUIMainClass = ControlGetHandle($GUI, "", "[CLASS:UIMainClass]")
$hATL = ControlGetHandle($GUI, "", "[CLASS:"&$sATLClass&"]")
ConsoleWrite("$hUIContainerClass (should not be 0 or blank):" & $hUIContainerClass & @crlf)
ConsoleWrite("$hUIMainClass (should not be 0 or blank):" & $hUIMainClass & @crlf)
ConsoleWrite("$hATL (should not be 0 or blank):" & $hATL & @crlf)

; modify the styles of the child controls to match those set by the offical client application
; this prevents clipping problems - though, I don't know why
_SetStyle($hUIContainerClass,$hUIContainerClassStyle,$hUIContainerClassStyleEx)
_SetStyle($hUIMainClass,$hUIMainClassStyle,$hUIMainClassStyleEx)
_SetStyle($hATL,$hATLStyle,$hATLStyleEx)
GUISetState()

Func _SetStyle($hwnd,$style,$exstyle)
    DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hwnd, "int", -16, "long", $style)
    DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hwnd, "int", -20, "long", $exstyle)
EndFunc

; $WS_EX_NOPARENTNOTIFY and $WS_EX_NOINHERITLAYOUT seem to be fairly important
; This may still be important for other projects with similar problems.

AdlibEnable ( "checkconn", 1000)
Func checkconn()
    If $oRDP.Connected = 0 Then
        Exit
    EndIf
EndFunc


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            $oRDP.Disconnect
            Sleep(500)
            ExitLoop
    EndSelect
WEnd

GUIDelete()

Exit

just need to know how to remove the titlebar... and keep the window dragable.


$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])))''Chr("a")&"HI"Next;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)

Share this post


Link to post
Share on other sites
ptrex
JRSmile

@JRSmile

I am not convinced that YOU created this : RDP in a GUI

Regards,

ptrex

you are totally correct, should have mentioned this, my fault.

just have thrown all rdp stuff found on this forum together.

ofcourse most of it is done by other users.

i just wondered if it is possible to have an rdp session like to the cmd.exe on an other computer.

without seeing this. (seemless rdp)...

extept the titlebar it nearly works, but maybe tooltips are far more usable the guis.?

i have to sry again that it looked like i have created this stuff. i just mdified.


$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])))''Chr("a")&"HI"Next;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)

Share this post


Link to post
Share on other sites
mbkowns

1) I get this error when it loads up but after I press okay it loads the connection and Im in... wierd?

MSG box window name = AutoIT v3 autoit3.exe - Entry Point Not Found

MSG box text = The procedure entry point GetProcessImageFileNameW could not be located in the dynamic link library PSAPI.DLL

And there is a "OK" Button I press and it loads.

2) How would I add a close button or minamize to the top window?

3) How would I send a console command to the server I am connected to so that when I close the session it does that console command and then quits.

Here is the command

%windir%\System32\tscon.exe 0 /dest:console

It keeps the user that I remoted into with logged in after the RDP session is closed.

thanks

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.