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. Office関連

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

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

  2. Office関連

    KB2553154の更新プログラムをアンインストールするVBScript

    2014/12/11 追記:当記事で紹介しているのは更新プログラム…

  3. Windows関連

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

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

  4. Excel

    フォルダ内にあるExcelファイルをカウントするVBScript

    「フォルダ内 Excel 数える VBScript」といったキーワード…

  5. Windows関連

    Windows 8を従来のスタイルに変更するスクリプト

    2012/3/2 追記:下記情報はWindows Develope…

  6. Office関連

    古い形式のWordテンプレートを新しい形式に一括変換するVBScript

    古い形式のWordテンプレート(dot)を新しい形式(dotx,dot…

コメント

  • コメント (0)

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

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

Time limit is exhausted. Please reload CAPTCHA.

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

Translate

最近の記事

アーカイブ

PAGE TOP