LoginSignup
9
7

More than 5 years have passed since last update.

VBSをVBEに変換し暗号化する方法

Last updated at Posted at 2018-10-04

VBSの中身を閲覧されたり変更されたくない場合に参考にして下さい。
VBSをVBEに変換して暗号化する方法を記載します。

概要

VBScriptをVBEに変換し暗号化します。

encode.vbsの作成

以下のソースコードをメモ帳に書いて「encode.vbs」という名前で保存します。

encode.vbs
Option Explicit 

dim oEncoder, oFilesToEncode, file, sDest 
dim sFileOut, oFile, oEncFile, oFSO, i 
dim oStream, sSourceFile 


set oFilesToEncode = WScript.Arguments 
set oEncoder = CreateObject("Scripting.Encoder") 
For i = 0 to oFilesToEncode.Count - 1 
    set oFSO = CreateObject("Scripting.FileSystemObject") 
    file = oFilesToEncode(i) 
    set oFile = oFSO.GetFile(file) 
    Set oStream = oFile.OpenAsTextStream(1) 
    sSourceFile=oStream.ReadAll 
    oStream.Close 
    sDest = oEncoder.EncodeScriptFile(".vbs",sSourceFile,0,"") 
    sFileOut = Left(file, Len(file) - 3) & "vbe" 
    Set oEncFile = oFSO.CreateTextFile(sFileOut) 
    oEncFile.Write sDest 
    oEncFile.Close 

Next

変換し暗号化する方法

暗号化したいvbsファイルを上記で作成した「encode.vbs」にドラックアンドドロップすると自動生成されます。

9
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
7