locked
Script to Export Favorites from Internet Explorer RRS feed

  • Question

  • Hello,

    Is there a Visual Basic script that can be written to export Internet Explorer Favorites to a bookmark.htm file?

    Thanks.

    Monday, March 22, 2010 6:48 AM

Answers

  • Here's one that exports the favorites to a bookmark.htm file:

    Const FAVOURITES = &H6&

    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace(FAVOURITES)
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objBookMark = objFSO.CreateTextFile(".\bookmark.htm", 2)
    objBookMark.WriteLine "<TITLE>Bookmarks</TITLE>"
    objBookMark.WriteLine "<H1>Bookmarks</H1>"
    objBookMark.WriteLine "<DL><p>"
    For Each objItem in objFolder.Items
        If objItem.IsLink Then
            Set objLink = objItem.GetLink
            objBookMark.Write "<A HREF=""" & objLink.Target & """>" & objItem.Name & "</A></br>"
        End If
    Next
    objBookMark.WriteLine "</DL></p>"
    objBookMark.Close

    Regards,

    Salvador Manaois III
    MCSE MCSA MCTS MCITP C|EH CIWA
    ----------------------------------------------------------------------------
    Bytes & Badz: http://badzmanaois.blogspot.com
    My Passion: http://www.flickr.com/photos/badzmanaois
    My Scripting Blog: http://sgwindowsgroup.org/blogs/badz  

     

    • Proposed as answer by Andrew Barnes Monday, March 22, 2010 8:01 PM
    • Marked as answer by IamMred Tuesday, March 23, 2010 3:27 PM
    Monday, March 22, 2010 7:43 AM

All replies

  • Here's one that exports the favorites to a bookmark.htm file:

    Const FAVOURITES = &H6&

    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace(FAVOURITES)
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objBookMark = objFSO.CreateTextFile(".\bookmark.htm", 2)
    objBookMark.WriteLine "<TITLE>Bookmarks</TITLE>"
    objBookMark.WriteLine "<H1>Bookmarks</H1>"
    objBookMark.WriteLine "<DL><p>"
    For Each objItem in objFolder.Items
        If objItem.IsLink Then
            Set objLink = objItem.GetLink
            objBookMark.Write "<A HREF=""" & objLink.Target & """>" & objItem.Name & "</A></br>"
        End If
    Next
    objBookMark.WriteLine "</DL></p>"
    objBookMark.Close

    Regards,

    Salvador Manaois III
    MCSE MCSA MCTS MCITP C|EH CIWA
    ----------------------------------------------------------------------------
    Bytes & Badz: http://badzmanaois.blogspot.com
    My Passion: http://www.flickr.com/photos/badzmanaois
    My Scripting Blog: http://sgwindowsgroup.org/blogs/badz  

     

    • Proposed as answer by Andrew Barnes Monday, March 22, 2010 8:01 PM
    • Marked as answer by IamMred Tuesday, March 23, 2010 3:27 PM
    Monday, March 22, 2010 7:43 AM
  • Thank you Salvador!
    Monday, March 22, 2010 7:54 AM
  • No problem. =)

    Regards,
    Salvador

    Monday, March 22, 2010 8:11 AM
  • Hi

    I know this is old, but this is exactly what I'm after.

    The code that Salvador provided works perfectly... except it only exports .LNKs / URLs  in the Favorites root.

    Is anyone able to provide a little more scripting information to create and preserve the .LNKs / URLs in subfolders please?

    Many thanks, Phil

    Tuesday, August 13, 2013 11:09 AM
  • Hello

    Excellent script but i also need to be able to export the Favourites bar, can that be added to the script as well, i know absolutly nothing about scripting so hope you can help.

    Regards Mick 

    Tuesday, April 29, 2014 8:47 AM
  • Newbie question: why is &H6& the Favorites directory?  I can't find any reference as to where this comes from, though it obviously works!

    Also same question as those below: how to dig into the favorites sub-folders? Though I hope to tackle that one myself.

    Tuesday, January 9, 2018 9:24 PM
  • In VB it is a HEX number.

    \_(ツ)_/


    • Edited by jrv Tuesday, January 9, 2018 10:00 PM
    Tuesday, January 9, 2018 9:59 PM
  • Fair enough. So H6 refers to a HEX number, the question now becomes why is 6 a reference to the Favorites directory? Thanks for your help!
    Thursday, January 11, 2018 2:51 PM
  • The Devil is in the details.

    The answer is ... because that is how it is defined.


    \_(ツ)_/

    Thursday, January 11, 2018 3:12 PM
  • Suggestion:  When learning about programming always start by looking in the API documentation.

    #2 - VB and VBScript are obsolete and will soon disappear.  Use PowerShell

    PS > [System.Environment+SpecialFolder]::Favorites
    Favorites
    PS > [System.Environment+SpecialFolder]::Favorites
    Favorites
    PS > [environment]::GetFolderPath([System.Environment+SpecialFolder]::Favorites)
    C:\Users\jjones\Favorites
    PS > dir [environment]::GetFolderPath([System.Environment+SpecialFolder]::Favorites)
    PS > dir ([environment]::GetFolderPath([System.Environment+SpecialFolder]::Favorites))
    
        Directory: C:\Users\jjones\Favorites
    
    
    Mode                LastWriteTime         Length Name
    ----                -------------         ------ ----
    d-----       11/29/2017   4:34 PM                ACA
    d-----       11/22/2017  11:34 AM                Acer
    d-----       11/22/2017  11:34 AM                AD Machine Accounts
    d-----       12/13/2017  12:20 AM                ADO

    Also:

    PS > [enum]::GetNames([System.Environment+SpecialFolder])
    Desktop
    Programs
    MyDocuments
    Personal
    Favorites
    Startup
    Recent
    SendTo
    StartMenu
    MyMusic
    MyVideos
    DesktopDirectory
    MyComputer
    NetworkShortcuts
    Fonts
    Templates
    CommonStartMenu
    CommonPrograms
    CommonStartup
    CommonDesktopDirectory
    ApplicationData
    PrinterShortcuts
    LocalApplicationData
    InternetCache
    Cookies
    History
    CommonApplicationData
    Windows
    System
    ProgramFiles
    MyPictures
    UserProfile
    SystemX86
    ProgramFilesX86
    CommonProgramFiles
    CommonProgramFilesX86
    CommonTemplates
    CommonDocuments
    CommonAdminTools
    AdminTools
    CommonMusic
    CommonPictures
    CommonVideos
    Resources
    LocalizedResources
    CommonOemLinks
    CDBurning
    PS >


    \_(ツ)_/


    • Edited by jrv Thursday, January 11, 2018 3:25 PM
    Thursday, January 11, 2018 3:25 PM