openFolderURL.vbs
Dim path, rawPath
Set fso = CreateObject("Scripting.FileSystemObject")
Set shell = CreateObject("Wscript.Shell")
' クリップボードからパスを取得する
On Error Resume Next
rawPath = CreateObject("htmlfile").ParentWindow.ClipboardData.GetData("text")
On Error GoTo 0
If IsEmpty(rawPath) Or IsNull(rawPath) Then
MsgBox "クリップボードの内容が文字列ではありません。"
Else
' クリップボードの内容がダブルクォーテーションで囲まれているか確認
If Left(rawPath, 1) = """" And Right(rawPath, 1) = """" Then
path = rawPath
rawPath = Mid(rawPath, 2, Len(rawPath) - 2) ' ダブルクォーテーションを取り除く
Else
path = """" & rawPath & """"
End If
' URLの場合はEdgeで開く
If InStr(LCase(rawPath), "http://") > 0 Or InStr(LCase(rawPath), "https://") > 0 Then
shell.Run "microsoft-edge:" & rawPath
'shell.Run "chrome.exe " & rawPath 'chromeで開く場合
Else
' ファイルパスとして有効かどうかをチェック
If fso.FolderExists(rawPath) Or fso.FileExists(rawPath) Or Left(rawPath, 2) = "\\" Then
' 有効な場合はエクスプローラで開く
shell.Run "explorer " & path
Else
MsgBox "無効なファイルパスです: " & rawPath
End If
End If
End If
(26行あたりURLを開くブラウザを変更)
Edge(デフォルト)
shell.Run "microsoft-edge:" & rawPath
Chrome
shell.Run "chrome.exe " & rawPath
ショートカットをデスクトップに作成してショートカットキーを割り当て