JScript / VBScript : 指定したフォルダ内のフォルダ毎の使用済みサイズを読める範囲でレポートする

▼ JScript のダウンロード

▼ VBScript のダウンロード

System Volume Information は、無駄に使われてる場合が多いそうです。( 今日 5G 削除しました ) ✅ 参考ページ

show-folders-size.js

// ************************************************
// カンマ編集
// ************************************************
String.prototype.number_format = 
function (prefix) {
	var num = this.valueOf();
	prefix = prefix || '';
	num += '';
	var splitStr = num.split('.');
	var splitLeft = splitStr[0];
	var splitRight = splitStr.length > 1 ? '.' + splitStr[1] : '';
	var regx = /(\d+)(\d{3})/;
	while (regx.test(splitLeft)) {
		splitLeft = splitLeft.replace(regx, '$1' + ',' + '$2');
	}
	return prefix + splitLeft + splitRight;
}

// ************************************************
// オブジェクト
// ************************************************
var Shell = new ActiveXObject("Shell.Application");
var WshShell = new ActiveXObject("WScript.Shell");
var Fso = new ActiveXObject( "Scripting.FileSystemObject" );

// ************************************************
// 管理者権限のコマンドプロンプトで再実行
// ************************************************
if ( WScript.Arguments.length == 0 ) {
	Shell.ShellExecute( "cmd.exe", "/c cscript.exe " + Dd(WScript.ScriptFullName) + " next" + " & pause", "", "runas", 1 );
	WScript.Quit();
}


var target = SelectDir( "対象フォルダを選択して下さい" )
if ( target == "" ) {
	WScript.Quit();
}

WScript.Echo( target )

// ************************************************
// フォルダオブジェクト取得
// ************************************************
var objFolder =  Fso.GetFolder(target)

var folderCollection = new Enumerator(objFolder.SubFolders);

var TargetSize = 0;
var obj;
var num;
var line;
for ( ;!folderCollection.atEnd(); folderCollection.moveNext()) {

	obj = folderCollection.item();
	
	try {
		num = Math.floor(obj.Size / 1024) / 1024;
		num = Math.floor( num * 1000 ) / 1000
		line = Lpad(("" + num).number_format()," ", 15) + " M : " + obj.Name
		WScript.Echo( line );

		// フォルダ全体の合計
		TargetSize = TargetSize + obj.Size
	}
	catch(e) {
		WScript.Echo( obj.Name + " : 処理できません");
	}

}

WScript.Echo( "" );

num = Math.floor(TargetSize / 1024) / 1024;
num = Math.floor( num * 1000 ) / 1000
line = Lpad(("" + num).number_format()," ", 15) + " M : " + "表示合計"
WScript.Echo( line );

// ************************************************
// ディレクトリ選択
// ************************************************
function SelectDir( strTitle ) {

	var obj

	obj = Shell.BrowseForFolder( 0, strTitle, 0x4B, 0 )
	if ( obj == null ) {
		return "";
	}
	if ( !obj.Self.IsFileSystem ) {
		ErrorMessage = "ファイルシステムではありません";
		return "";
	}

	return obj.Self.Path;

}

// ************************************************
// ダブルクォートで囲む
// ************************************************
function Dd( strValue ) {

	return "\"" + strValue + "\""

}

// ************************************************
// 指定数、指定文字列左側を埋める
// ※少数以下3桁の調整
// ************************************************
function Lpad( strValue, str, nLen ) {

	var i;
	var wk = "";

	for( i = 0; i < nLen; i++ ) {
		wk += str;
	}
	
	var test = strValue.split(".");
	if ( test.length == 2 ) {
		if ( test[1].length == 0 ) {
			strValue += "000"
		}
		if ( test[1].length == 1 ) {
			strValue += "00"
		}
		if ( test[1].length == 2 ) {
			strValue += "0"
		}
	}
	else {
		strValue += ".000"
	}

	return ( wk + strValue ).slice( nLen * -1 );

}


show-folders-size.vbs

' ************************************************
' 管理者権限で実行用
' ************************************************
Set Shell = CreateObject( "Shell.Application" )

' ************************************************
' 管理者権限で再実行
' ************************************************
if Wscript.Arguments.Count = 0 then
	Shell.ShellExecute "cmd.exe", "/c cscript.exe " & Dd(WScript.ScriptFullName) & " next" & " & pause", "", "runas", 1
	Wscript.Quit
end if

' ************************************************
' 除外フォルダ名を スペースで区切って並べる
' (簡易的な除外)
' ************************************************
Dim Exclude
Exclude = ".gem"
Exclude = Lcase(Exclude)

' ************************************************
' 処理用
' ************************************************
Set WshShell = CreateObject( "WScript.Shell" )
Set Fso = CreateObject( "Scripting.FileSystemObject" )

Dim target

' ************************************************
' 対象フォルダを選択
' ************************************************
target = SelectDir( "対象フォルダを選択して下さい" )
if target = "" then
	Wscript.Quit
end if

Wscript.Echo target
Wscript.Echo

' ************************************************
' フォルダオブジェクト取得
' ************************************************
Set objFolder =  Fso.GetFolder(target)

' ************************************************
' サブフォルダコレクション取得
' ************************************************
Set colSubFolder =  objFolder.SubFolders

' ************************************************
' 一覧
' ************************************************
Dim TargetSize : TargetSize = 0
For Each obj in colSubFolder

	Do While true

		if InStr(Exclude,Lcase(obj.Name)) > 0 then
			Exit Do
		end if

		on error resume next
		Wscript.Echo Lpad(FormatNumber((Fix(obj.Size / 1024) / 1024),3)," ", 15) & " M : " & obj.Name
		if Err.Number <> 0 then
			Wscript.Echo "                  ( " & obj.Name & " : 処理できません )"
		else
			TargetSize = TargetSize + obj.Size
		end if
		on error goto 0


		Exit Do
	Loop


Next

Wscript.Echo

Dim AllSize
Dim er : er = 0
on error resume next
AllSize = objFolder.Size
if Err.Number <> 0 then
	er = 1
	AllSize	= TargetSize
end if
on error goto 0


Wscript.Echo Lpad(FormatNumber((Fix(TargetSize / 1024) / 1024),3)," ", 15) & " M : " & "表示合計"

if er = 1 then
	Wscript.Echo "                  ( " & target & " のサイズは取得できませんでした )"
else
	Wscript.Echo Lpad(FormatNumber((Fix(AllSize / 1024) / 1024),3)," ", 15) & " M : " & target & " のサイズ"
end if

Dim fsize : fsize = 0
For Each file in objFolder.files
	fsize = fsize + file.size
Next
Wscript.Echo Lpad(FormatNumber((Fix((fsize) / 1024) / 1024),3)," ", 15) & " M : " & target & " 下のファイル"

Wscript.Echo

' ************************************************
' ディレクトリ選択
' ************************************************
Function SelectDir( strTitle )

	Dim obj

	Set obj = Shell.BrowseForFolder( 0, strTitle, &H4B, 0 )
	if obj is nothing then
		SelectDir = ""
		Exit Function
	end if
	if not obj.Self.IsFileSystem then
		ErrorMessage = "ファイルシステムではありません"
		SelectDir = ""
		Exit Function
	end if

	SelectDir = obj.Self.Path

End Function

' ************************************************
' ダブルクォートで囲む
' ************************************************
Function Dd( strValue )

	Dd = """" & strValue & """"

End function

' ************************************************
' 指定数、指定文字列左側を埋める
' ************************************************
Function Lpad( strValue, str, nLen )

	Lpad = Right( String(nLen,str) & strValue, nLen )

End Function






VBScript, ツール

MKEditor 追加設定インストーラ : プロジェクト自動作成スクリプトをエクスプローラの『新規作成』に追加します

MKEditor for Windows のダウンロード( Vector )

まず、MKEditor をインストールしておきます。その後から以下からダウンロードする書庫の中の install.bat を実行させます。





このスクリプトは、MKEditor の追加の設定を自動で行います。実行後、フォルダの選択ダイアログが表示されるので、MKEditor のインストールフォルダを選択して下さい



MKEditor.sck のキー割り当て

1) shift+f1 でアプリケーションで実行
2) shift+ctrl+del で、アイテム削除
3) f2 でボックス、フォルダ、アイテムのプロパティ
4) f4 で、フォルダ作成
5) Shift+f4 でボックス作成
6) Shift+Ctrl+U で 大文字( Upper )
7) Shift+Ctrl+L で 小文字( Lower )
8) Shift+Ctrl+Z で 全角
9) Shift+Ctrl+H で 半角
10) F5 相対パスでリンク
11) Shift+@ でエディタオプション
▼ MKEditor プロジェクトの実行 そのフォルダ内のみ対象とします ▼ MKEditor プロジェクト(全て)の実行 / 下の階層もすべて作成 全てのサブディレクトリも登録します。 但し、それらは常に1階層のディレクトリとしますので、深いツリー構造でも管理しやすくなります。 ( 空のディレクトリも登録しますし、CTRL + SHIFT + DEL で削除も容易です ) ▼ 対象拡張子の追加 MKEditor のインストール場所に build_mkp.wsf と build_mkp_all.wsf があります。その先頭付近に以下のような記述がありますので、これに追加します。
strList = ""
strList = strList & "CSV,PHP,HTM,TXT,INF,VBS,ASP,INC,WSF,ASA,ASPX,BAS,CSS,JS,SQL,SQLTXT,BAT,PS1,JAVA,JSP,VB,"
strList = strList & "HTA,HTM,HTML,SHTM,SHTML,PL,CGI,C,CPP,H,URL,REG,LOG,AS,MXML,XUL,DTD,PROPERTIES,MANIFEST,RDF,INI,"
strList = strList & "PY,RB,CS,PAS,DPR,TSV,XML,SH"
アンインストール 以下のキーをレジストリから削除してください
HKEY_CLASSES_ROOT\.layla002
HKEY_CLASSES_ROOT\.layla003

エクスプローラを右クリックしてそのフォルダで「コマンドプロント」を開くメニューを追加する( .reg ファイルを実行 )

エクスプローラを右クリックしてコマンドプロンプトを開きたい場合は、以下のレジストリをインポートします(右端のダウンロードアイコンでダウンロード / 拡張子 .reg )
Windows Registry Editor Version 5.00
 
[HKEY_CLASSES_ROOT\Folder\shell\cmd]
@="コマンドプロンプト(&Q)"
 
[HKEY_CLASSES_ROOT\Folder\shell\cmd\command]
@="cmd.exe /s /k pushd \"%V\""

HKEY_CLASSES_ROOT\Folder なのがミソです。同様の HKEY_CLASSES_ROOT\Directory は所有者が特殊でいろいろ面倒です
🔻 ショートカットは他とダブらないように Q にしました 🔻 SHIFT キーを押しながら右クリック
🔻 削除は以下です
Windows Registry Editor Version 5.00
 
[-HKEY_CLASSES_ROOT\Folder\shell\cmd]
 


🔻 インストール場所をレジストリエディタで開くスクリプトをダウンロードします




VBScript : ファイルのパスや名前をクリップボードへ( ダブルクォートなし ) / 送るフォルダに保存

エクスプローラで、SHIFT キーを押しながら右クリックすると『パスとしてコピー』がありますが、ダブルクォートが付加されています( たいていはそのほうがいいのですが )ので、ダブルクォートのないパスを取得します


▼ こんな感じで取得されます
"C:\Program Files\7-Zip\7-zip.dll"

filepath.vbs( SendTo ディレクトリに置いてください )

Set WshShell = Wscript.CreateObject("WScript.Shell")
Set Fso = Wscript.CreateObject("Scripting.FileSystemObject")

strTemp = WshShell.ExpandEnvironmentStrings("%temp%")
strPath = strTemp & "\__clipCommand.tmp"

Set objHandle = Fso.OpenTextFile( strPath, 2, True )
objHandle.Write Wscript.Arguments(0)

Call WshShell.Run( "cmd.exe /c clip < """ & strPath & """", 0, True )
▼ こうなります
C:\Program Files\7-Zip\7-zip.dll

以下はディレクトリ部分を省いた名前の部分のみをクリップボードにコピーします。

filename.vbs( SendTo ディレクトリに置いてください )

Set WshShell = Wscript.CreateObject("WScript.Shell")
Set Fso = Wscript.CreateObject("Scripting.FileSystemObject")

strTemp = WshShell.ExpandEnvironmentStrings("%temp%")
strPath = strTemp & "\__clipCommand.tmp"

Set objHandle = Fso.OpenTextFile( strPath, 2, True )
strName = Wscript.Arguments(0)
aPath = Split(strName,"\")
strName = aPath(Ubound(aPath))
objHandle.Write strName

Call WshShell.Run( "cmd.exe /c clip < """ & strPath & """", 0, True )

▼ こうなります
7-zip.dll

さらに以下では、複数ファイルを選択した場合のファイル名部分だけを取り出して複数行としてコピーします( 但しあまり大量のファイルは元々の文字列の制限によりエラーとなります

filelist.vbs( SendTo ディレクトリに置いてください )

Set WshShell = Wscript.CreateObject("WScript.Shell")
Set Fso = Wscript.CreateObject("Scripting.FileSystemObject")

str = ""
For I = 0 to Wscript.Arguments.Count-1
	aData = Split( Wscript.Arguments(I), "\" )
	str = str & aData(Ubound(aData)) & vbCrLf
Next

strTemp = WshShell.ExpandEnvironmentStrings("%temp%")
strPath = strTemp & "\__clipCommand.tmp"

Set objHandle = Fso.OpenTextFile( strPath, 2, True )
objHandle.Write str
Call WshShell.Run( "cmd.exe /c clip < """ & strPath & """", 0, True )

▼ ファイルが多すぎて起きるエラー


▼ うまくいくとこんな感じです
nslookup.exe
ntdll.dll
odbc32.dll
ole32.dll


操作補足

エクスプローラで SendTo フォルダに移動するには、アドレスバーに sendto と直接入力します。テンポラリフォルダは、%temp% と入力して下さい。




コードを直接ダウンロードした場合は、右クリックのプロパティより『許可する』にチェックしておきます。






Google 翻訳ブックマークレット

テキストを選択してブックマークレットを実行すると、その部分だけを翻訳し、なにも選択せずにただブックマークレットを実行するとそのページ全体を翻訳します
🔻 以下のリンクをブックマークバーにドロップしてください
Google英→日

Google日→英

Edge の場合は一旦何かのお気に入りを作成してから、上記リンクのコピーを編集で URL に対して置き換える必要があります
🔻 このページの英語翻訳 🔻 Google英→日 のソースコード
javascript: (function() {
	var b = ((window.getSelection && window.getSelection()) || (document.getSelection && document.getSelection()) || (document.selection && document.selection.createRange && document.selection.createRange().text));
	if (b != '') {
		window.open('https://translate.google.co.jp/?hl=ja&tab=wT#en/ja/' + encodeURIComponent(b));
	} else {
		window.open('https://translate.google.co.jp/translate?sl=en&tl=ja&js=n&prev=_t&hl=ja&ie=UTF-8&u=' + encodeURIComponent(location.href) + '&act=url');
	}
})();

🔻 Google日→英 のソースコード
javascript: (function() {
	var b = ((window.getSelection && window.getSelection()) || (document.getSelection && document.getSelection()) || (document.selection && document.selection.createRange && document.selection.createRange().text));
	if (b != '') {
		window.open('https://translate.google.co.jp/?hl=ja&tab=wT#ja/en/' + encodeURIComponent(b));
	} else {
		window.open('https://translate.google.co.jp/translate?sl=ja&tl=en&js=n&prev=_t&hl=ja&ie=UTF-8&u=' + encodeURIComponent(location.href) + '&act=url');
	}
})();




XCOPY で新しいファイルのみバックアップする為のスクリプトを作成するスクリプト / VBScript

⭕ ディレクトリ選択でバックアップするフォルダを決定 ⭕ カレント(このスクリプトを実行したフォルダ)にスクリプトが作成されます ⭕ 新しいスクリプトを実行 ⭕ カレントにバックアップ用のフォルダが作成されます ⭕ バックアップするフォルダ内をそのフォルダ内に全てコピーします ▼ 実行時に表示されるフォルダ選択 XCOPY なので、2回目以降は新しいファイルのみコピーします ▼ 作成されたスクリプトのサンプルです
strName = "BK_C_temp_lightbox"
strTarget = "C:\temp\lightbox"
strBackupFolder = "C:\tmp\vbs"
if MsgBox( strTarget & vbCrLf & "のバックアップを開始します。よろしいですか? (保存先:" & strBackupFolder & "\" & strName & ")", 1 ) = 2 then
	Wscript.Quit
end if
Set WshShell = Wscript.CreateObject( "WScript.Shell" )
ExecCommand = "cmd.exe /C ""xcopy.exe """ & strTarget & """ """ & strBackupFolder & "\" & strName & "\"" /D /E /C /S /Y & PAUSE"""
Call WshShell.Run( ExecCommand )


▼ 使用するオプション
/D : コピー元の日付がコピー先の日付より新しいファイルだけをコピーします
/E : ディレクトリまたはサブディレクトリが空であってもコピーします
/C : エラーが発生してもコピーを続けます
/S : 空の場合を除いて、ディレクトリとサブディレクトリをコピーします
/Y : 既存のファイルを上書きする前に確認のメッセージを表示しません
一番重要なのは、/D です。/S /E で、存在するディリクトリはすべてコピーされます。/E /Y によって、最後まで停止する事なく実行されます。 追加で使う事が想定されるオプション コピーしたくないディレクトリやファイルがある場合、以下のように指定します。 /EXCLUDE:ファイルのパス ファイルのパスが示すテキストファイル内に、除外するディレクトリやファイルにある文字列の一部を1 行に 1 つずつ記述します。 その文字列が、コピー対象ファイルの絶対パスの一部と一致した場合、そのファイルはコピーから除外されます。 ▼ 例 ⭕ "\obj\" という文字列を指定するとディレクトリ obj の下の全ファイルが除外 されます。 ⭕ ".obj" という文字列を指定すると .obj という拡張子のファイルがすべて除外されます ソースコード
' ***********************************************************
' 処理開始
' ***********************************************************
Set Fso = Wscript.CreateObject( "Scripting.FileSystemObject" )
Set Shell = Wscript.CreateObject( "Shell.Application" )

' ***********************************************************
' 実行中ディレクトリの取得
' ***********************************************************
strPath = Wscript.ScriptFullName 
Set objFile = Fso.GetFile( strPath )
strBackupFolder = Fso.GetParentFolderName( objFile )

' ***********************************************************
' バックアップ対象ディレクトリの取得
' ***********************************************************
' ① 省略すると、ルートはデスクトップ
Set objFolder = Shell.BrowseForFolder( 0, "バックアップするフォルダを選択してください", &H4B )

' ② 文字列による直接指定
' strRoot = "c:\"
' Set objFolder = Shell.BrowseForFolder( 0, "バックアップするフォルダを選択してください", &H4B, strRoot )

' ③ ルートを番号で指定( この場合は C:\Users\username\AppData\Local )
' ※ あまり現実的ではない特殊ディレクトリの選択
' nRoot = &h1c
' Set objFolder = Shell.BrowseForFolder( 0, "バックアップするフォルダを選択してください", &H4B, nRoot )

if objFolder is nothing then
	WScript.Quit
end if
if not objFolder.Self.IsFileSystem then
	WScript.Echo "ファイルシステムではありません"
	WScript.Quit
end if

strTargetFolder = objFolder.Self.Path
strName = Replace( strTargetFolder, ":", "" )
strName = Replace( strName, "\", "_" )
strName = Replace( strName, " ", "" )
strName = "BK_" & strName

' ***********************************************************
' スクリプト作成
' ***********************************************************
Set OutFile = Fso.OpenTextFile( strBackupFolder & "\" & strName & ".vbs", 2, True )

OutFile.WriteLine "strName = """ & strName & """"
OutFile.WriteLine "strTarget = """ & strTargetFolder & """"
OutFile.WriteLine "strBackupFolder = """ & strBackupFolder & """"
OutFile.Write "if MsgBox( strTarget & vbCrLf & ""のバックアップを開始します。よろしいですか? (保存先:"" & strBackupFolder & ""\"" & strName & "")"""
OutFile.WriteLine ", 1 ) = 2 then"
OutFile.WriteLine "	Wscript.Quit"
OutFile.WriteLine "end if"

OutFile.WriteLine "Set WshShell = Wscript.CreateObject( ""WScript.Shell"" )"
OutFile.Write "ExecCommand = ""cmd.exe /C """"xcopy.exe """""" & strTarget & """""" """""" & strBackupFolder & ""\"" & strName & ""\"""""
OutFile.WriteLine " /D /E /C /S /Y & PAUSE"""""""
OutFile.WriteLine "Call WshShell.Run( ExecCommand )"

OutFile.Close

WScript.Echo "バックアップスクリプト : " &  strName & ".vbs" & " を作成しました"


' ***********************************************************
' ディレクトリ指定用番号
' https://docs.microsoft.com/ja-jp/windows/desktop/api/shldisp/ne-shldisp-shellspecialfolderconstants
' typedef enum {
' 	ssfALTSTARTUP = 0x1d,
' 	ssfAPPDATA = 0x1a,
' 	ssfBITBUCKET = 0x0a,
' 	ssfCOMMONALTSTARTUP = 0x1e,
' 	ssfCOMMONAPPDATA = 0x23,
' 	ssfCOMMONDESKTOPDIR = 0x19,
' 	ssfCOMMONFAVORITES = 0x1f,
' 	ssfCOMMONPROGRAMS = 0x17,
' 	ssfCOMMONSTARTMENU = 0x16,
' 	ssfCOMMONSTARTUP = 0x18,
' 	ssfCONTROLS = 0x03,
' 	ssfCOOKIES = 0x21,
' 	ssfDESKTOP = 0x00,
' 	ssfDESKTOPDIRECTORY = 0x10,
' 	ssfDRIVES = 0x11,
' 	ssfFAVORITES = 0x06,
' 	ssfFONTS = 0x14,
' 	ssfHISTORY = 0x22,
' 	ssfINTERNETCACHE = 0x20,
' 	ssfLOCALAPPDATA = 0x1c,
' 	ssfMYPICTURES = 0x27,
' 	ssfNETHOOD = 0x13,
' 	ssfNETWORK = 0x12,
' 	ssfPERSONAL = 0x05,
' 	ssfPRINTERS = 0x04,
' 	ssfPRINTHOOD = 0x1b,
' 	ssfPROFILE = 0x28,
' 	ssfPROGRAMFILES = 0x26,
' 	ssfPROGRAMFILESx86 = 0x30,
' 	ssfPROGRAMS = 0x02,
' 	ssfRECENT = 0x08,
' 	ssfSENDTO = 0x09,
' 	ssfSTARTMENU = 0x0b,
' 	ssfSTARTUP = 0x07,
' 	ssfSYSTEM = 0x25,
' 	ssfSYSTEMx86 = 0x29,
' 	ssfTEMPLATES = 0x15,
' 	ssfWINDOWS = 0x24
' } ShellSpecialFolderConstants;
' ***********************************************************




関連する Microsoft ドキュメント

Shell Reference
Shell Objects for Scripting and Microsoft Visual Basic
Shell object
Shell.BrowseForFolder method



Google Chrome のアドレス部分に書き込む簡易エディタ



以下をクリックして選択状態にして、Google Chrome のブックマークバーへドラッグすると、ブックマークレットとしていつでも実行できるようになります。( タイトルは編集で変更してください )
▲ このテキストを Google Chrome のアドレスへ書き込むだけで簡易的なテキストエディタになり、ローカルへ SHIFT_JIS で保存する事ができ、既存のテキスト( SHIFT_JIS と Unicode と UTF8:BOMあり )を読み込む事ができます。

▼ もちろん、通常のWEB ページ上で使用する事もできます

以下が【保存用】のテスト用ソースコードです。( 改行コードが CRLF になるように処理しています )
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.8/FileSaver.min.js"></script>
<script src="https://winofsql.jp/js/encoding.js"></script>
<script src="https://winofsql.jp/js/save-sjis.js"></script>

<script>
$( function(){

	$("#save-action").on("click", function(){

		// テキストエリアのテキストを jQuery で取得		
		var text = $("#save-text").val();
		// lf のみを crlf に変換
		text = text.replace(/\n/g, '\r\n');
		// ローカルに保存する
		save_sjis( "save-sjis.txt", text );
	});

});
</script>
<div><input type="button" id="save-action" value="Save as Shift_JIS"></div>
<textarea id="save-text" style='width:400px;height:100px;'></textarea>


▼ save-sjis.js の内容です
var load_save_file_name = null;

var str2array = function(str) {

	var array = [],i,il=str.length;
	for(i=0;i<il;i++) array.push(str.charCodeAt(i));
	return array;

};

function save_sjis( filename, str ) {

	var array = str2array( str );
	var sjis_array = Encoding.convert(array, "SJIS", "UNICODE");
	var sjis_data = new Uint8Array(sjis_array);

	if ( load_save_file_name != null ) {
		filename = load_save_file_name;
	}

	saveAs(
		new Blob(
			[sjis_data]
			, {type: "text/plain;charset=shift_jis"}
		)
		, filename
	);

}

function load_sjis( event, target ) {

	var file = event.target.files[0];
	load_save_file_name = file.name;

	var reader = new FileReader();
	reader.onload = function(event) {
		target.value = event.target.result;
	};

	reader.readAsText(file,"shift_jis");

}


▼ 読込みのサンプルは以下のようになります
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://winofsql.jp/js/save-sjis.js"></script>

<script>
$( function(){

	$("#get-text").on("change", function( event ){

		load_sjis( event, $("#save-text").get(0) );

	});

});
</script>
<div><input type="file" id="get-text"></div>
<textarea id="save-text" style='width:400px;height:100px;'></textarea>





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





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


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

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



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

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

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

dump.vbs( 作業フォルダーに置いてください )
if WScript.Arguments.Count = 1 then
	strMessage = "送るから実行して下さい" & vbCrLf & vbCrLf
	strMessage = strMessage & "※ リンク先の最後の数字はコマンドプロンプトの行数です   " & vbCrLf
	strMessage = strMessage & "※ プロパティよりウインドウを最大化する方法もあります   " & vbCrLf
	Call MsgBox(strMessage,0,"lightbox")
	Wscript.Quit
end if

Set WshShell = CreateObject( "WScript.Shell" )   
Set Fso = CreateObject( "Scripting.FileSystemObject" )

strCurPath = WScript.ScriptFullName
Set obj = Fso.GetFile( strCurPath )
Set obj = obj.ParentFolder
strCurPath = obj.Path

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


dump_c.vbs
' ****************************************************
' ファイルを16進数でダンプします
' ****************************************************
Dim Fs,Stream
Dim InFile
Dim Kana
Dim KjFlg
Kana = Array( _
"。","「","」","、","・","ヲ","ァ","ィ","ゥ","ェ","ォ","ャ","ュ","ョ","ッ", _
"ー","ア","イ","ウ","エ","オ","カ","キ","ク","ケ","コ","サ","シ","ス","セ","ソ", _
"タ","チ","ツ","テ","ト","ナ","ニ","ヌ","ネ","ノ","ハ","ヒ","フ","ヘ","ホ","マ", _
"ミ","ム","メ","モ","ヤ","ユ","ヨ","ラ","リ","ル","レ","ロ","ワ","ン","゙","゚" )

Set Fs = CreateObject( "Scripting.FileSystemObject" )
Set Stream = CreateObject("ADODB.Stream")

InFile = WScript.Arguments(0)

Dim LineBuffer,DispBuffer,CWork,nCnt,strBuff,i,j

if not Fs.FileExists( InFile ) then
	Wscript.Echo "ファイルが存在しません"
	Wscript.Quit
end if

' ------------------------------------------------------
' Stream のオープン
Stream.Open
 
' ------------------------------------------------------
' Stream タイプの指定
Stream.Type = 1		' StreamTypeEnum の adTypeBinary
 
' ------------------------------------------------------
' 既存ファイルの内容を Stream に読み込む
Stream.LoadFromFile InFile
 
' ------------------------------------------------------
' バイナリ型の Stream オブジェクトからを読み取って加工
Bcnt = 0
nCnt = 0
KjFlg = ""

Do while not Stream.EOS

	if ( nCnt MOD 16 ) = 0 then
		Wscript.Echo "          0  1  2  3  4  5  6  7" _
		& "  8  9  A  B  C  D  E  F"
		Wscript.Echo "--------------------------------" _
		& "------------------------------------------"
	end if

	' 16 バイトの読込
	LineBuffer = Stream.Read(16)

	strBuff = ""
	For i = 1 to LenB( LineBuffer )
		CWork = MidB(LineBuffer,i,1)
		Cwork = AscB(Cwork)
		Cwork = Hex(Cwork)
		Cwork = Ucase(Cwork)
		Cwork = Right( "0" & Cwork, 2 )
		DispBuffer = DispBuffer & Cwork & " "
		strBuff = strBuff & CharConv( Cwork )
	Next

	Wscript.Echo _
		Right( _
			"00000000" & Ucase(Hex( nCnt * 16 )), 8 _
		) & " " & _
		Left(DispBuffer & String(49," "), 49 ) & strBuff
	DispBuffer = ""

	nCnt = nCnt + 1
 
Loop
 
' ------------------------------------------------------
' Stream を閉じる
Stream.Close

Set Stream = Nothing
Stream = Empty
Set Fs = Nothing
Fs = Empty

' ****************************************************
' 生データのテキスト
' ****************************************************
function CharConv( HexCode )

	Dim nCode

	nCode = Cint( "&H" & HexCode )

	if KjFlg = "" then
		if &H81 <= nCode and nCode <= &H84 or _
			&H88 <= nCode and nCode <= &H9f or _
			&HE0 <= nCode and nCode <= &HEA then
			KjFlg = HexCode
			CharConv = ""
			Exit Function
		end if
	else
		if HexCode <> "00" then
			KjFlg = KjFlg & HexCode
			CharConv = Chr( Cint( "&H" & KjFlg ) )
		else
			CharConv = ".."
		end if
		KjFlg = ""
		Exit Function
	end if

	if 0 <= nCode and nCode <= &H1F then
		CharConv = "."
	end if
	if &H20 <= nCode and nCode <= &H7E then
		CharConv = Chr(nCode)
	end if
	if &H7F <= nCode and nCode <= &HA0 then
		CharConv = "."
	end if
	if &HA1 <= nCode and nCode <= &HDF then
		CharConv = Kana(nCode-&HA1)
	end if
	if &HE0 <= nCode and nCode <= &HFF then
		CharConv = "."
	end if

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 と直接入力します。





IE11のソースエディタの変更 / VBScript

最新の IE11 では、HKEY_CURRENT_USER でしか動作しないようです。





全て VBScript のみで実行しています。ですから、ファイル参照ウインドウの表示が、現在表示しているウインドウに隠れたりする場合があるので注意して下さい。

ieSrcEditor.wsf をエクスプローラから実行すると、ファイルを参照するダイアログが開きます。内部のコードは以下のようになっていますが、必要な関数等はインターネット上に保存して使用しています。ここでは、ローカルのファイルを開いてパスを取得する為に、InternetExplorer.Application を使用しています。

アンインストールは、zip 内の uninstall.reg か 以下のテキストを uninstall.reg として shift_jis か Unicode で保存してエクスプローラから実行します。内部は、Microsoft の仕様によるレジストリエントリの削除記述となっています。ですから、実際削除を行うのは、regedit.exe です。
Windows Registry Editor Version 5.00

[-HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\View Source Editor]


▼ 実行用のソースコードです
<JOB>
<COMMENT>
************************************************************
 WEB WSH 実行スケルトン
************************************************************
</COMMENT>

<COMMENT>
************************************************************
 外部スクリプト定義
************************************************************
</COMMENT>
<SCRIPT
	language="VBScript"
	src="http://lightbox.in.coocan.jp/laylaClass.vbs">
</SCRIPT>

<SCRIPT language=VBScript>
' 管理者として実行を強制する
Set obj = Wscript.CreateObject("Shell.Application")
if Wscript.Arguments.Count = 0 then
	obj.ShellExecute "wscript.exe", WScript.ScriptFullName & " runas", "", "runas", 1
	Wscript.Quit
end if

' ***********************************************************
' 処理開始
' ***********************************************************
Call laylaFunctionTarget( "http://lightbox.in.coocan.jp/" )
Call laylaLoadFunction( "baseFunction.vbs" )
Call laylaLoadFunction( "wmiReg.vbs" )
Call laylaLoadFunction( "toolFunction.vbs" )

' **********************************************************
' エディタ選択
' **********************************************************
strValue = OpenLocalFileName
if strValue = "" then
	Wscript.Quit
end if

' **********************************************************
' レジストリ
' **********************************************************
strPath = "SOFTWARE\Microsoft\Internet Explorer\View Source Editor\Editor Name"
Call WMIRegCreateKey( HKEY_CURRENT_USER, strPath )
strValue = Dd( strValue )
Call WMIRegSetStringValue( HKEY_CURRENT_USER, strPath, Empty, strValue )

MsgOk( strValue & " を IE のソースエディタとして登録しました" )

Function OpenLocalFileName( )

	Call GetObj( "IEDocument", "InternetExplorer.Application" )
	IEDocument.Navigate( ScriptDir( ) & "\local.htm" )
	IEDocument.document.getElementsByTagName("BODY")(0).innerHTML = "<input id=FilePath type=file>"
	IEDocument.document.getElementById("FilePath").click
	if IEDocument.document.getElementById("FilePath").value = "" then
		OpenLocalFileName = ""
		IEDocument.Quit
		Set IEDocument = Nothing
		Exit Function
	end if

	OpenLocalFileName = IEDocument.document.getElementById("FilePath").value

	IEDocument.Quit
	Set IEDocument = Nothing

End Function
</SCRIPT>
</JOB>






コンピュータアイコンにメニューを追加する

※ Windows の大きなアップデートで消える可能性はありますが、自分の好きなコマンドでカスタマイズできるので便利です。

▼ Windows10


▼ インストールするレジストリのキー
HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell

現状ではおそらくレジストリの該当場所の所有者が TrustedInstaller となっており、Administrators グループに権限が無いと思います。

いったん所有者を Administrators グループ に変更してから、Administrators グループ にアクセス権限を与えます。その後にレジストリのインポートを行って下さい。


アクセス許可を選択して表示されたダイアログの詳細設定ボタンをクリックして、表示された『shell のセキュリティの詳細設定』というダイアログの先頭にある『変更リンク』で所有者を変更します。

Administrators に変更した後、アクセス許可で Administrators にフルコントロールを設定します。


▼ 解凍後の内容 ▼ README
************************************************************
コンピュータアイコンメニュー設定レジストリデータ

■ 事前準備

	インストール場所を開く.bat をエクスプローラからダブル
	クリックしてレジストリエディタを起動し、選択されている
	キーの所有者を自分が所属する Administrators グループに
	変更して、Administrators にフルコントロールを設定します

■ インストール

	computer_menu をエクスプローラからタブルクリック
	してインポートして下さい

■ アンインストール

	uninstall_computer_menu をエクスプローラからタブル
	クリックして下さい


■ 登録された場所でレジストリエディタを開く
	インストール場所を開く.bat をエクスプローラからタブ
	ルクリックして下さい

■著作権その他

このプログラムはフリーです。どうぞ自由に御使用ください。
著作権は作者である私(lightbox)が保有しています。
また、本ソフトを運用した結果については、作者は一切責任を
負えせんのでご了承ください。
************************************************************
computer_menu.reg
001 : mmc.exe "%SystemRoot%\system32\services.msc" /s
002 : "%ProgramFiles%\Common Files\Microsoft Shared\MSInfo\msinfo32.exe"
003 : RunDLL32.EXE shell32.dll,Control_RunDLL appwiz.cpl
004 : RunDLL32.EXE shell32.dll,Control_RunDLL odbccp32.cpl
005 : regedit.exe
006 : %SystemRoot%\system32\cmd.exe
007 : UserAccountControlSettings.exe
008 : mmc.exe "%windir%\system32\eventvwr.msc" /s
009 : rundll32.exe netplwiz.dll,UsersRunDll
010 : rundll32.exe sysdm.cpl,EditEnvironmentVariables
011 : cmd.exe /c powershell -NoProfile -ExecutionPolicy unrestricted -WindowStyle hidden -Command "start notepad.exe %SystemRoot%\system32\drivers\etc\hosts -verb runas"
012 : RUNDLL32.EXE shell32.dll,Options_RunDLL 7
013 : mmc.exe "%windir%\system32\taskschd.msc" /s
014 : mmc.exe "%SystemRoot%\system32\gpedit.msc"
015 : mstsc.exe
016 : control.exe /name Microsoft.WindowsUpdate
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\001]
@="   サービス"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\001\command]
@=hex(2):6d,00,6d,00,63,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,00,53,00,79,\
  00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,00,5c,00,73,00,79,00,\
  73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,73,00,65,00,72,00,76,00,69,00,63,\
  00,65,00,73,00,2e,00,6d,00,73,00,63,00,22,00,20,00,2f,00,73,00,00,00

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\002]
@="   システム情報"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\002\command]
@=hex(2):22,00,25,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,46,00,69,00,6c,\
  00,65,00,73,00,25,00,5c,00,43,00,6f,00,6d,00,6d,00,6f,00,6e,00,20,00,46,00,\
  69,00,6c,00,65,00,73,00,5c,00,4d,00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,\
  00,74,00,20,00,53,00,68,00,61,00,72,00,65,00,64,00,5c,00,4d,00,53,00,49,00,\
  6e,00,66,00,6f,00,5c,00,6d,00,73,00,69,00,6e,00,66,00,6f,00,33,00,32,00,2e,\
  00,65,00,78,00,65,00,22,00,00,00

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\003]
@="   プログラムと機能"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\003\command]
@="RunDLL32.EXE shell32.dll,Control_RunDLL appwiz.cpl"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\004]
@="   ODBC アドミニストレータ"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\004\command]
@="RunDLL32.EXE shell32.dll,Control_RunDLL odbccp32.cpl"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\005]
@="   レジストリエディタ"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\005\command]
@="regedit.exe"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\006]
@="   コマンドプロンプト"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\006\command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
  00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,63,00,6d,00,\
  64,00,2e,00,65,00,78,00,65,00,00,00

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\007]
@="   UAC"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\007\command]
@=hex(2):55,00,73,00,65,00,72,00,41,00,63,00,63,00,6f,00,75,00,6e,00,74,00,43,\
  00,6f,00,6e,00,74,00,72,00,6f,00,6c,00,53,00,65,00,74,00,74,00,69,00,6e,00,\
  67,00,73,00,2e,00,65,00,78,00,65,00,00,00

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\008]
@="   イベント ビューアー"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\008\command]
@=hex(2):6d,00,6d,00,63,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,00,77,00,69,\
  00,6e,00,64,00,69,00,72,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,\
  33,00,32,00,5c,00,65,00,76,00,65,00,6e,00,74,00,76,00,77,00,72,00,2e,00,6d,\
  00,73,00,63,00,22,00,20,00,2f,00,73,00,00,00

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\009]
@="   ユーザーアカウント"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\009\command]
@="rundll32.exe netplwiz.dll,UsersRunDll"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\010]
@="   環境変数"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\010\command]
@="rundll32.exe sysdm.cpl,EditEnvironmentVariables"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\011]
@="   HOSTS"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\011\command]
@=hex(2):63,00,6d,00,64,00,2e,00,65,00,78,00,65,00,20,00,2f,00,63,00,20,00,70,\
  00,6f,00,77,00,65,00,72,00,73,00,68,00,65,00,6c,00,6c,00,20,00,2d,00,4e,00,\
  6f,00,50,00,72,00,6f,00,66,00,69,00,6c,00,65,00,20,00,2d,00,45,00,78,00,65,\
  00,63,00,75,00,74,00,69,00,6f,00,6e,00,50,00,6f,00,6c,00,69,00,63,00,79,00,\
  20,00,75,00,6e,00,72,00,65,00,73,00,74,00,72,00,69,00,63,00,74,00,65,00,64,\
  00,20,00,2d,00,57,00,69,00,6e,00,64,00,6f,00,77,00,53,00,74,00,79,00,6c,00,\
  65,00,20,00,68,00,69,00,64,00,64,00,65,00,6e,00,20,00,2d,00,43,00,6f,00,6d,\
  00,6d,00,61,00,6e,00,64,00,20,00,22,00,73,00,74,00,61,00,72,00,74,00,20,00,\
  6e,00,6f,00,74,00,65,00,70,00,61,00,64,00,2e,00,65,00,78,00,65,00,20,00,25,\
  00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,00,5c,00,\
  73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,64,00,72,00,69,00,76,\
  00,65,00,72,00,73,00,5c,00,65,00,74,00,63,00,5c,00,68,00,6f,00,73,00,74,00,\
  73,00,20,00,2d,00,76,00,65,00,72,00,62,00,20,00,72,00,75,00,6e,00,61,00,73,\
  00,22,00,00,00

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\012]
@="   フォルダオプション"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\012\command]
@="RUNDLL32.EXE shell32.dll,Options_RunDLL 7"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\013]
@="   タスク スケジューラ"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\013\command]
@=hex(2):6d,00,6d,00,63,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,00,77,00,69,\
  00,6e,00,64,00,69,00,72,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,\
  33,00,32,00,5c,00,74,00,61,00,73,00,6b,00,73,00,63,00,68,00,64,00,2e,00,6d,\
  00,73,00,63,00,22,00,20,00,2f,00,73,00,00,00

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\014]
@="   ローカル グループ ポリシーエディタ"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\014\command]
@=hex(2):6d,00,6d,00,63,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,00,53,00,79,\
  00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,00,5c,00,73,00,79,00,\
  73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,67,00,70,00,65,00,64,00,69,00,74,\
  00,2e,00,6d,00,73,00,63,00,22,00,00,00

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\015]
@="   リモートデスクトップ"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\015\command]
@="mstsc.exe"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\016]
@="   Windows Update"

[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\016\command]
@="control.exe /name Microsoft.WindowsUpdate"


▼ インストール場所


▼ インストール場所を レジストリエディタで開く VBScript
strParam = Trim( "HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell" )
' 無ければ、クリップボード
if strParam = "" then
	' クリップボード用
	' ※ HTA 等では直接 window.clipboardData より実行
	' ※ するように書き換える必要があります
	Set objIE = CreateObject("InternetExplorer.Application")
	objIE.Navigate("about:blank")
	Do While objIE.Busy
		' 100 ミリ秒
		Wscript.Sleep 100
	Loop
	strParam = objIE.document.parentWindow.clipboardData.GetData( "Text" ) & ""
	objIE.Quit
end if
strParam = Trim( strParam )
' 無ければ入力
if strParam = "" then
	strParam = InputBox("開く対象となるレジストリーのキーを入力して下さい")
end if
if strParam = "" then
	Wscript.Quit
end if

' レジストリ書き込み用
Set WshShell = CreateObject( "WScript.Shell" )
' WMI用
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

' レジストリエディタが最後に開いていたキーの登録を行います
strPath = "Software\Microsoft\Windows\CurrentVersion\Applets\Regedit\LastKey"
if GetOSVersion() >= 6 then
	strRegPath = "コンピューター\" & strParam
else
	strRegPath = "マイ コンピュータ\" & strParam
end if

' 既に regedit が実行中の場合はいったん終了させます
Set colProcessList = objWMIService.ExecQuery _ 
	("Select * from Win32_Process Where Name = 'regedit.exe'") 
For Each objProcess in colProcessList
	' 最後のウインドウの位置とサイズを保存する為の終わらせ方
	WshShell.AppActivate("レジストリ エディタ")
	Wscript.Sleep(500)
	WshShell.SendKeys ("%{F4}")
	Wscript.Sleep(500)
	' 上記終わらせ方が失敗した時の強制終了
	on error resume next
	objProcess.Terminate() 
	on error goto 0
Next 

WshShell.RegWrite "HKCU\" & strPath, strRegPath, "REG_SZ"

' レジストリエディタを起動します
Call WshShell.Run( "regedit.exe" )
' レジストリエディタが終わるまで待つ場合は以下のようにします
' Call WshShell.Run( "regedit.exe", , True )

REM **********************************************************
REM OS バージョンの取得
REM **********************************************************
Function GetOSVersion()

	Dim colTarget,str,aData,I,nTarget

	Set colTarget = objWMIService.ExecQuery( _
		 "select Version from Win32_OperatingSystem" _
	)
	For Each objRow in colTarget
		str = objRow.Version
	Next

	aData = Split( str, "." )
	For I = 0 to Ubound( aData )
		if I > 1 then
			Exit For
		end if
		if I > 0 then
			nTarget = nTarget & "."
		end if
		nTarget = nTarget & aData(I)
	Next

	GetOSVersion = CDbl( nTarget )

End Function