Monthly Archive

Add a favourite to Internet Explorer

Way back in this post

I mentioned about adding a new favourite. 

Favourites are special folders and one way to work with them is through the old COM objects

function add-favourite{             
$so = New-Object -ComObject Shell.Application            
$ff = $so.Namespace(0x6)            
$path = Join-Path -Path $($ff.Self.Path) -ChildPath "$name.url"             
$shell = New-Object -ComObject WScript.Shell            
$sc = $shell.CreateShortCut($path)            
$sc.TargetPath = $url            
Add a new favourite

Add a new favourite

add-favourite -name mytest -url ""


The name for the favourite and the URL are parameters. Create a object for the Favourites folder and then a path for the favourite. Use CreateShorcut on the WScript.Shell object add the URL and save

Leave a Reply