Skip to main content
Kofax

Transferring a binary file between two machines when Clipboard is the only interface

3020761

Question / Problem: 

A file needs to be transferred from one machine to the other. Neither a file transfer option nor the internet/FTP are available. But the Windows clipboard is available as an interface (RDPClip.exe). When the file to be transferred is Text, the solution is easy: Open Notepad on machine 1, load file, mark/copy all, open Notepad on machine 2, paste, save file, done. But what if the file is binary (e.g a DLL or an EXE or a ZIP)?

Answer / Solution: 

Use the according Powershell commands to convert the Binary to String and back, so Notepad and copy/paste can be used for the transfer.

Enter How to here:

  1. On machine 1:
    $to = Get-Content -Encoding Byte -Path c:\temp\example.exe      /* the .exe is loaded as bytestream into the Variable $to

  2. [convert]::ToBase64String($to) > c:\temp\example.txt         /* the string is written into a Textfile

  3. notepad c:\temp\example.txt, mark all, copy all, start notepad on machine 2, paste all, save file to c:\temp\example.txt

  4. on machine 2:
    $fro =[convert]::FromBase64String((get-content -path c:\temp\example.txt))     /* the way back: the Textfile gets converted into a Variable

  5. [io.file]::WriteAllBytes("c:\temp\example.exe", $fro)            /* all bytes from the variable are being written into the .exe 

 

Applies to:  

Product Version
all all

 

 

  • Was this article helpful?