Somebody over at ITNinja recently asked how they could run an executable stored in the binary table, from a VBScript Custom Action. Here’s an example I knocked up which describes how to extract an EXE from the binary table and run it from a VBScript Custom Action. I basically streamed notepad.exe into the binary table, and gave it a name of ‘notepad’. In this Custom Action, I extract it to the %temp% folder and run it from there. Note that there is no cleanup of the extraction afterwards. Also note that because this uses the Session object, it can only be executed in the Immediate context. So more consideration would be required (and probably a separate Custom Action) to execute the extracted EXE in a deferred context.
Below is an updated version that extracts from the binary table using msiReadStreamDirect
(as a binary string), converts the string to binary and outputs it using ADODB.Stream
. It may resolve locale-specific issues with the aforementioned approach.
Finally, i verified the file imported into the Binary table against the file extracted from the Binary table using this simple command line:
fc.exe /b [full_path_file_1] [full_path_file_2]