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

    GUIDを作成するVBScript

    Office アドインを作成するのに必要(マニフェストのId要素)なG…

  2. Office関連

    [Mayhem]PowerPointマクロにショートカットキーを割り当てる。

    2012/4/20 追記:クイックアクセスツールバーのメニューを利用す…

  3. VBScript

    動画回転用簡易FFmpegフロントエンド

    アーケードゲームのプレイを録画した際、機器によっては録画した動画の向き…

  4. Windows関連

    右クリックメニューからフォルダを管理者権限で開く(コマンド プロンプト)

    フォルダをShiftキーを押しながら右クリックすると、「コマンド ウィ…

  5. VBScript

    Windows Updateの更新履歴をCSV(UTF-8)で保存するVBScript

    以前書いたスクリプトが出てきました。Windows Updateの…

コメント

  • コメント (0)

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

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

Time limit is exhausted. Please reload CAPTCHA.

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

Translate

最近の記事

アーカイブ

PAGE TOP