' 管理者として実行を強制する
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
' ファイルシステムを操作するオブジェクト
Set Fso = WScript.CreateObject( "Scripting.FileSystemObject" )
' テンポラリフォルダ
TempDir = Fso.GetSpecialFolder(2)
on error resume next
' テンポラリフォルダに空の "local.htm" を作成
Set objHandle = Fso.CreateTextFile( TempDir & "\local.htm", True, True )
if Err.Number <> 0 then
Wscript.Quit
end if
objHandle.Close
on error goto 0
' IE を操作するオブジェクト
Set IEDocument = WScript.CreateObject( "InternetExplorer.Application" )
' テンポラリフォルダに作成したファイルを開く
IEDocument.Navigate( TempDir & "\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
Wscript.Quit
end if
' 選択したファイルのパスを戻す
Wscript.Echo IEDocument.document.getElementById("FilePath").value
' IE を終了
IEDocument.Quit
Set IEDocument = Nothing