「送る」に入れる簡易ダンプ ( VBScript )





※コマンドプロンプトの操作
Q : 終了します。
スペースキー : 次ページを表示します。
Enterキー : 次の行を表示します


自分で環境を作って、VBScript のコードファイルも自分で配置する場合は以下をご覧下さい。

SendTo フォルダにショートカットを作成する



この時、作業フォルダーを用意してそこに VBScript のコードファイルを保存します。実行するコマンドラインは以下のようになっています。

%windir%\system32\wscript.exe dump.vbs 35

35 は、コマンドプロンプトに一度に表示する行数です

dump.vbs( 作業フォルダーに置いてください )
01.if WScript.Arguments.Count = 1 then
02.        strMessage = "送るから実行して下さい" & vbCrLf & vbCrLf
03.        strMessage = strMessage & "※ リンク先の最後の数字はコマンドプロンプトの行数です   " & vbCrLf
04.        strMessage = strMessage & "※ プロパティよりウインドウを最大化する方法もあります   " & vbCrLf
05.        Call MsgBox(strMessage,0,"lightbox")
06.        Wscript.Quit
07.end if
08. 
09.Set WshShell = CreateObject( "WScript.Shell" )  
10.Set Fso = CreateObject( "Scripting.FileSystemObject" )
11. 
12.strCurPath = WScript.ScriptFullName
13.Set obj = Fso.GetFile( strCurPath )
14.Set obj = obj.ParentFolder
15.strCurPath = obj.Path
16. 
17.strCommand = "cmd /c mode CON lines="&WScript.Arguments(0)&" & cscript.exe """ & _
18.strCurPath & "\dump_c.vbs"" """ & WScript.Arguments(1) & """ | more & pause"
19.Call WshShell.Run( strCommand )

dump_c.vbs
001.' ****************************************************
002.' ファイルを16進数でダンプします
003.' ****************************************************
004.Dim Fs,Stream
005.Dim InFile
006.Dim Kana
007.Dim KjFlg
008.Kana = Array( _
009."。","「","」","、","・","ヲ","ァ","ィ","ゥ","ェ","ォ","ャ","ュ","ョ","ッ", _
010."ー","ア","イ","ウ","エ","オ","カ","キ","ク","ケ","コ","サ","シ","ス","セ","ソ", _
011."タ","チ","ツ","テ","ト","ナ","ニ","ヌ","ネ","ノ","ハ","ヒ","フ","ヘ","ホ","マ", _
012."ミ","ム","メ","モ","ヤ","ユ","ヨ","ラ","リ","ル","レ","ロ","ワ","ン","゙","゚" )
013. 
014.Set Fs = CreateObject( "Scripting.FileSystemObject" )
015.Set Stream = CreateObject("ADODB.Stream")
016. 
017.InFile = WScript.Arguments(0)
018. 
019.Dim LineBuffer,DispBuffer,CWork,nCnt,strBuff,i,j
020. 
021.if not Fs.FileExists( InFile ) then
022.        Wscript.Echo "ファイルが存在しません"
023.        Wscript.Quit
024.end if
025. 
026.' ------------------------------------------------------
027.' Stream のオープン
028.Stream.Open
029.  
030.' ------------------------------------------------------
031.' Stream タイプの指定
032.Stream.Type = 1         ' StreamTypeEnum の adTypeBinary
033.  
034.' ------------------------------------------------------
035.' 既存ファイルの内容を Stream に読み込む
036.Stream.LoadFromFile InFile
037.  
038.' ------------------------------------------------------
039.' バイナリ型の Stream オブジェクトからを読み取って加工
040.Bcnt = 0
041.nCnt = 0
042.KjFlg = ""
043. 
044.Do while not Stream.EOS
045. 
046.        if ( nCnt MOD 16 ) = 0 then
047.                Wscript.Echo "          0  1  2  3  4  5  6  7" _
048.                & "  8  9  A  B  C  D  E  F"
049.                Wscript.Echo "--------------------------------" _
050.                & "------------------------------------------"
051.        end if
052. 
053.        ' 16 バイトの読込
054.        LineBuffer = Stream.Read(16)
055. 
056.        strBuff = ""
057.        For i = 1 to LenB( LineBuffer )
058.                CWork = MidB(LineBuffer,i,1)
059.                Cwork = AscB(Cwork)
060.                Cwork = Hex(Cwork)
061.                Cwork = Ucase(Cwork)
062.                Cwork = Right( "0" & Cwork, 2 )
063.                DispBuffer = DispBuffer & Cwork & " "
064.                strBuff = strBuff & CharConv( Cwork )
065.        Next
066. 
067.        Wscript.Echo _
068.                Right( _
069.                        "00000000" & Ucase(Hex( nCnt * 16 )), 8 _
070.                ) & " " & _
071.                Left(DispBuffer & String(49," "), 49 ) & strBuff
072.        DispBuffer = ""
073. 
074.        nCnt = nCnt + 1
075.  
076.Loop
077.  
078.' ------------------------------------------------------
079.' Stream を閉じる
080.Stream.Close
081. 
082.Set Stream = Nothing
083.Stream = Empty
084.Set Fs = Nothing
085.Fs = Empty
086. 
087.' ****************************************************
088.' 生データのテキスト
089.' ****************************************************
090.function CharConv( HexCode )
091. 
092.        Dim nCode
093. 
094.        nCode = Cint( "&H" & HexCode )
095. 
096.        if KjFlg = "" then
097.                if &H81 <= nCode and nCode <= &H84 or _
098.                        &H88 <= nCode and nCode <= &H9f or _
099.                        &HE0 <= nCode and nCode <= &HEA then
100.                        KjFlg = HexCode
101.                        CharConv = ""
102.                        Exit Function
103.                end if
104.        else
105.                if HexCode <> "00" then
106.                        KjFlg = KjFlg & HexCode
107.                        CharConv = Chr( Cint( "&H" & KjFlg ) )
108.                else
109.                        CharConv = ".."
110.                end if
111.                KjFlg = ""
112.                Exit Function
113.        end if
114. 
115.        if 0 <= nCode and nCode <= &H1F then
116.                CharConv = "."
117.        end if
118.        if &H20 <= nCode and nCode <= &H7E then
119.                CharConv = Chr(nCode)
120.        end if
121.        if &H7F <= nCode and nCode <= &HA0 then
122.                CharConv = "."
123.        end if
124.        if &HA1 <= nCode and nCode <= &HDF then
125.                CharConv = Kana(nCode-&HA1)
126.        end if
127.        if &HE0 <= nCode and nCode <= &HFF then
128.                CharConv = "."
129.        end if
130. 
131.end function

ショートカットを直接実行すると、以下のようなダイアログが出ます



最大化は、dump.vbs の 17行目からを、画面の解像度に合わせてカラム数を以下のように設定して実行時のウインドウを選択すると実装できます( ただ、ダンプの表示幅が決まっているのでこの場合あまり意味ありません )

strCommand = "cmd /c mode CON cols=160 & cscript.exe """ & _
strCurPath & "\dump_c.vbs"" """ & WScript.Arguments(1) & """ | more & pause"
Call WshShell.Run( strCommand, 3 )

操作補足

エクスプローラで SendTo フォルダに移動するには、アドレスバーに sendto と直接入力します。