Skip to content

Instantly share code, notes, and snippets.

@auycro
Created December 16, 2014 23:50
Show Gist options
  • Save auycro/d93e2449dad894afc908 to your computer and use it in GitHub Desktop.
Save auycro/d93e2449dad894afc908 to your computer and use it in GitHub Desktop.
microsoft-script-encode-vbs
'Option Explicit
'Sub aa()
Dim oEncoder, oFile, oFSO 'As Object
Dim oStream, sSourceFile
Dim sDest, sFileOut, oEncFile
Set oEncoder = CreateObject("Scripting.Encoder")
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.GetFile("C:\ExcelMacro.vbs")
Set oStream = oFile.OpenAsTextStream(1)
sSourceFile = oStream.ReadAll
oStream.Close
sDest = oEncoder.EncodeScriptFile(".vbs", sSourceFile, 0, "")
sFileOut = "C:\ExcelMacroEncoded.vbe"
Set oEncFile = oFSO.CreateTextFile(sFileOut)
oEncFile.Write sDest
oEncFile.Close
'End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment