Manage bookmarks in internet explorer

Hi all,

Please use below script to add and view bookmarks per user in internet explorer,

Edit parameter: Edit list of sites needs to be added as bookmarks

sitelist = “www.google.com,www.gmail.com,www.youtube.com

Note: script works well when Run as logged in user.


import os

sitelist = "www.google.com,www.gmail.com,www.youtube.com"

user=os.environ['USERNAME']


lines='''
Dim list
Dim urlnames

list = "%s"
urlnames=Split(list,",") 


Set obj = CreateObject("Scripting.FileSystemObject")


For i = 0 to UBound(urlnames)
  If i=UBound(urlnames) Then
    print=1
  Else 
    print=0
  End If 

  website=urlnames(i)
  name=Split(urlnames(i),".")
  url=name(1)
  addbookmark website,url,print 
  'Wscript.Echo website
  'Wscript.Echo url 
Next 




Sub addbookmark(website,url,print)
    'WScript.Echo website
    'WScript.Echo url 
    Const ADMINISTRATIVE_TOOLS = 6 
    dim Search
    Search = "C:\\Users\\%s\\Favorites\\"& url &".url"

    Set Shell = CreateObject("Shell.Application") 
    Set objFolder = Shell.Namespace(ADMINISTRATIVE_TOOLS)  
Set objFolderItem = objFolder.Self  


    Set objShell = WScript.CreateObject("WScript.Shell") 
    strDesktopFld = objFolderItem.Path 
    Set objURLShortcut = objShell.CreateShortcut(strDesktopFld & "/" & url& ".url")
    objURLShortcut.TargetPath = website

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    objStartFolder = objFolderItem.Path 
    Set objFolder = objFSO.GetFolder(objStartFolder)
    Set colFiles = objFolder.Files

    If objFSO.FileExists(Search) Then
        Wscript.Echo website & "----" & "This site already presents in bookmark "    
    Else 
        objURLShortcut.Save
        Wscript.Echo "The file Added to bookmarks list"
    end if


    If print=1 Then
    Wscript.Echo "   "    
    Wscript.Echo "Files presents in Favourites are:"    
        For Each objFile in colFiles
            Wscript.Echo objFile.Name
        Next
    End If
End Sub





'''

temp=os.environ['TEMP']
path=temp+'\\addbookmark.vbs'

print path
vblines =  lines % (sitelist,user)
files=open(path,'w+')
files.write(vblines)
files.close()

os.chdir(temp)

if 'PROGRAMW6432' in os.environ.keys():
    result=os.popen(r'C:\Windows\SysWOW64\cscript.exe addbookmark.vbs').read()
    print result
else:
    result=os.popen(r'C:\Windows\System32\cscript.exe addbookmark.vbs').read()
    print result





sample output

sample.png