Results 1 to 2 of 2

Thread: [RESOLVED] edit RDP file

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Resolved [RESOLVED] edit RDP file

    i want to edit the ip address in a remote desktop connection file, but it is a unicode file, when i read the file using line input then write it back out as a new rdp file it saves as unicode, but the text is ansi so it displays as weird characters
    i can convert the file to ansi so it diplays correctly, but i would prefer to keep it in the unicode

    Code:
    Open "mytest.rdp" For Input As 1
            Do While Not EOF(1)
                i = i + 1
                Line Input #1, strln
                If i = 6 Then
                    lnarr = Split(strln, ":")
                    lnarr(2) = vastip
                    strln = Join(lnarr, ":")
                End If
                    rdpstr = rdpstr & strln & vbNewLine
             Loop
           Close 1
    
        Open "mytest2.rdp" For Output As 1
            Print #1, rdpstr   ' Mid(rdpstr, 3), will save the file as ANSI
            Close 1
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: edit RDP file

    i have been able to solve this
    vb Code:
    1. Open "mytest2.rdp" For Output As 1
    2.         If Not InStr(rdpstr, Chr(&HFF) & Chr(&HFE)) = 0 Then rdpstr = Mid(rdpstr, 3)
    3.         ff(0) = &HFF
    4.         ff(2) = &HFE
    5.         Print #1, ff;
    6.         Print #1, StrConv(rdpstr, vbUnicode)
    7.         Close 1
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width