Jump to content

Edit RDP file


Recommended Posts

OK, we all know you can edit an RDP file in notepad, but when you try to use FileOpen -> FileReadLine in AutoIT on a .rdp file, it comes back with gibberish and blank lines. I'm hoping to add a function to edit rdp file settings in my rdp console script but this is kinda putting the brakes on it. Any one have any ideas on the type of encryption (if that is the case) that Micro$oft puts on the rdp files?

Viva-La AutoIT!!!

Edit

PS, wanted to create this script b/c the Remote Desktop Settings window does not give you all the functionality than is possible when compared to editing the settings in an rdp file in notepad... Hence my reason for wanting to create this script.

Edited by masonje
Link to comment
Share on other sites

May be Unicode. When you open an RDP file in Notepad, then do SaveAs, does the type default to Unicode?

:shocked:

Yes it does. I have never seen that option. What does that mean for AutoIT?

Edited by masonje
Link to comment
Share on other sites

Yes it does. I have never seen that option. What does that mean for AutoIT?

AutoIT does ASCII natively. To work with Unicode requires some translation. Use the search function on the forum and you'll probably find unicode filters already written for AutoIT. Alternatively, you can just open it in Notepad and then SaveAs | ANSI.

This comes up for .bks files for NTBackup too. The instructions all say you have to create the .bks file using the NTBackup GUI, but that's Microsoft Bovine Scat (MS-BS). It's just a unicode text file with plainly readable options that you can edit in Notepad.

:shocked:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Well, 3.2.3.6 Beta has some functions for particular control types, and the same ability in Send(), for example, that it has had for a long time to do:

Send("{ASC 0xA95}")

but that is not "full" unicode support by a long shot, and specifically does not address the original poster's question. Which of the new beta functions would allow you to read a line from a unicode text file, edit the line like with StringReplace(), and write it back to the file in unicode?

:shocked:

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Ok then this unicode link should address the poster's question.

Ooh...cool functions! I hadn't seen those particular ones. I especially like that the convert from ANSI to Unicode includes a flag to prefix the FF:FE mark to the output.

...

Func _StringToWCStr (ByRef $sString, $mark = 0)
    Local $sizeIn = StringLen ($sString), $sizeOut= BitShift ($sizeIn, -1)
    Local $bufOut, $ptrOut, $wordOut
    If $sizeIn =0 Then
        If $mark Then Return Chr(0xFF) & Chr(0xFE)
        Return ''
    EndIf
    If $mark Then
        $bufOut = DllStructCreate ("byte[" & $sizeOut +2 & "]")
        DllStructSetData ($bufOut, 1, Chr(0xFF) & Chr(0xFE))
        $ptrOut = DllStructGetPtr ($bufOut)
        $ptrOut +=2
    Else
        $bufOut = DllStructCreate ("byte[" & $sizeOut & "]")
        $ptrOut = DllStructGetPtr ($bufOut)
    EndIf
    Local $ret = DllCall ("Kernel32.dll", "int", "MultiByteToWideChar", _
        "int", 0, _
        "int", 0, _
        "str", $sString, _
        "int", $sizeIn,  _
        "ptr", $ptrOut,  _
        "int", $sizeOut )
    If $ret [0] Then
        Return DllStructGetData ($bufOut, 1)
    Else
        $ret = DllCall ("Kernel32.dll", "int", "GetLastError")
        SetError ($ret [0])
    EndIf
EndFunc


Func _WCStrToString (ByRef $wcString)
    Local $sizeIn= StringLen ($wcString), $sizeOut = BitShift ($sizeIn, 1)
    If $sizeIn =0 Then Return ''
    Local $bufOut= DllStructCreate ("char[" & $sizeOut & "]")
    Local $bufIn = DllStructCreate ("byte[" & $sizeIn  & "]")
    Local $ptrIn = DllStructGetPtr ($bufIn)
    DllStructSetData ($bufIn, 1, $wcString)
    If DllStructGetData ($bufIn, 1, 1) =-1 AND DllStructGetData ($bufIn, 1, 2) =-2 Then
        $ptrIn   +=2
        $sizeOut -=1
    EndIf
    Local $ret = DllCall ("Kernel32.dll", "int", "WideCharToMultiByte", _
        "int", 0, _
        "int", 0, _
        "ptr", $ptrIn, _
        "int", $sizeOut, _
        "ptr", DllStructGetPtr ($bufOut), _
        "int", $sizeOut, _
        "int", 0, _
        "int", 0 )   
    If $ret [0] Then
        Return DllStructGetData ($bufOut, 1)
    Else
        $ret = DllCall ("Kernel32.dll", "int", "GetLastError")
        SetError ($ret [0])
    EndIf
EndFunc
:shocked:
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Rock!!! Thanks for the help. I will give it a shot. :(

Ooh...cool functions! I hadn't seen those particular ones. I especially like that the convert from ANSI to Unicode includes a flag to prefix the FF:FE mark to the output.

:shocked:

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...