VBScript

Internet Explorerのお気に入りを列挙するVBScript

Internet Explorerのお気に入りにどの位のインターネットショートカットが登録されているのかを調べるスクリプト(対応ファイル形式:url,website)を書いてみました。

Option Explicit

Const CSIDL_FAVORITES = 6

ListIEFavorites CreateObject("Shell.Application") _
                  .Namespace(CSIDL_FAVORITES).Self.Path

Private Sub ListIEFavorites(ByVal TargetFolderPath)
  Dim fol, f
   
  With CreateObject("Scripting.FileSystemObject")
    If .GetFolder(TargetFolderPath).SubFolders.Count > 0 Then
      For Each fol In .GetFolder(TargetFolderPath).SubFolders
        ListIEFavorites fol.Path
      Next
    End If
    If .GetFolder(TargetFolderPath).Files.Count > 0 Then
      For Each f In .GetFolder(TargetFolderPath).Files
        Select Case LCase(.GetExtensionName(f.Path))
          Case "url"
            WScript.Echo f.Path & "," & GetShortcutTargetPathFromUrl(f.Path)
          Case "website"
            WScript.Echo f.Path & "," & GetShortcutTargetPathFromWebsite(f.Path)
        End Select
      Next
    End If
  End With
End Sub
 
Private Function GetShortcutTargetPathFromUrl(ByVal TargetFilePath)
'urlファイルからショートカットファイルのリンク先取得
  Dim ret
  
  With CreateObject("WScript.Shell")
    With .CreateShortcut(TargetFilePath)
      ret = .TargetPath
    End With
  End With
  GetShortcutTargetPathFromUrl = ret
End Function

Private Function GetShortcutTargetPathFromWebsite(ByVal TargetFilePath)
'websiteファイルからショートカットファイルのリンク先取得
  Dim ret, s
  
  With CreateObject("Scripting.FileSystemObject")
    With .OpenTextFile(TargetFilePath)
      Do Until .AtEndOfStream
        s = .ReadLine
        If LCase(Left(s, 4)) = "url=" Then
          ret = s
          Exit Do
        End If
      Loop
      .Close
    End With
  End With
  ret = Mid(ret, 5) '行頭の4文字(URL=)除外
  GetShortcutTargetPathFromWebsite = ret
End Function

このスクリプトを実行すると、下図のようにショートカットファイルのパスとリンク先URLを出力します。

「//Nologo」オプションを付けてリダイレクトすると、CSVファイルもすぐに作れて便利です。

2017年4月の人気記事前のページ

Microsoft Edgeの場所次のページ

関連記事

  1. VBScript

    指定したフォルダ内のemlファイルの情報をリスト化するVBScript

    emlファイルから件名や本文、宛先や送信日時といった各種情報を取得して…

  2. Windows関連

    特殊フォルダーのパスを取得するVBScript

    ファイルのコピーや移動を行う場合に特殊フォルダーのパスが必要になること…

  3. VBScript

    実行中のアプリケーション一覧を出力するVBScript

    「VBS アプリ一覧 出力」というキーワード検索での訪問があったので、…

  4. Windows 10

    Microsoft Edgeを起動するVBScript

    前回の記事の関連ですが、下記コードのようにShellExecuteメソ…

  5. Windows関連

    Lhaplusのバージョンを取得するVBScript

    およそ2年ぶりに圧縮・解凍ソフトの「Lhaplus」がバージョンアップ…

  6. VBScript

    Adobe Illustratorを操作するVBScript

    Acrobatと同様にタイプライブラリが用意されているため、VBAやV…

コメント

  • コメント (0)

  • トラックバックは利用できません。

  1. この記事へのコメントはありません。

Time limit is exhausted. Please reload CAPTCHA.

※本ページはプロモーションが含まれています。

Translate

最近の記事

アーカイブ

PAGE TOP