**DONOTDELETE**
(Lurker)
2003-07-24 12:09 AM
Adding IE Favourites

Hello All,
I am in need of some help from you good people. I am trying to add addresses to the IE favourites via kix to the users profile when they login.

Since, its possible to lock down the proxy address, I assuming this should be possible too. I would be grateful for assistance on this issue. Many thanks in advance. regards, Af.


Radimus
(KiX Supporter)
2003-07-24 01:26 AM
Re: Adding IE Favourites

there are many ways to do this:
copy the shortcut in from a network share
create the new shortcut in place

see WSHShortcut()in the UDF forum for the 'create' method

See fnAllSpecialFolders() for a method of determining the destination folder


**DONOTDELETE**
(Lurker)
2003-07-24 02:25 AM
Re: Adding IE Favourites

I had a look at the UDF forum. I want to achieve something like the following in the All users\favourites folder.

wshShortcut("KiXtart Web Page","http://www.kixtart.org")

I know I'm being stupid, but I'm still not quite sure how the code works. Do you have a simple example of what the code would look like to create the above shortcut and place it in the All users\favourites folder.

Also do I need to do anything extra to ensure the WSH function is working? I am using Kix 4.02

Many thanks for your assistance. Regards, AF.


Sealeopard
(KiX Master)
2003-07-24 02:45 AM
Re: Adding IE Favourites

Please read the FAQ Forum on how to use UDFs and read the UDF header for its functionality. The UDF header contains specific instruction on how to use it and illustrates it via an example.

The Favorites folder contains shortcuts with an .URL entension.

You might also want to consider updating kiXtart to v4.21.

For proxy settings see for example the SetProxy() UDF.


ChristopheM
(Hey THIS is FUN)
2003-07-24 11:25 AM
Re: Adding IE Favourites

an other solution is to create all the shortcuts on your station and then copy them to a shared place.

in your kix script, you copy theses files to the user profile.

I use these solution to set a common favorite subdir in the user favorites menu.
with the script below, I create the "your favorite" subdir with all favorites organized in subdirs. When the subdirs are ready, I use robocopy to update workstation. Copy is done the first time and then, only modified or added shortcut are copied

code:
break on

cls

$inifile = @scriptdir + "\" + @scriptname + ".ini"

$section = ReadProfileString ( $inifile, "", "")
$arrSection = split($section,chr(10))
for each $section in $arrSection
if $section
? "Répertoire $section"

$localpath = "Your Favorites\$section"
MD $localpath
$url = ReadProfileString ( $inifile, $section, "" )
$arrUrl = split($url,chr(10))
for each $url in $arrUrl
if $url
$desc = ReadProfileString ( $inifile, $section, $url )
$ = CreateURL( $url, $desc, $localpath )
endif
next
endif
next

exit 0

function CreateURL( $url, $description, $path )
? $vbTab + $url + $vbTab + $description
$WshShell = CreateObject("WScript.Shell")

if $description=""
$description=$url
endif

$oUrlLink = $WshShell.CreateShortcut("$path\$description.url")
$oUrlLink.TargetPath = "http://$url"
$oUrlLink.Save
endfunction

with the sample ini file below, I list the shortcut to be created
code:
[subdir 1]
www.microsoft.com=Microsoft Site
url2=description 2
url3=description 3

[subdir 1\subdir 1.1]
www.kixtart.org=kixtart site
http://www.kixtart.org/cgi-bin/Ultimatebb.cgi=kixtart bulletin board

[subdir 2]
url2=description 2

section name is the relative path name
key is the url
value is the description (the name of the shortcut file


**DONOTDELETE**
(Lurker)
2003-07-25 11:20 AM
Re: Adding IE Favourites

Thanks guys for all your help. All the code I've seen so far seems to be very long and overly complicated for what I wanted to acheive, So for lesser mortals like me, here is the very basic code that I used to create the shortcuts on the users favourites folder.

Note: for some reason VBScript does not run, so instead I used Java script.

Shell = new ActiveXObject("WScript.Shell");
DesktopPath = Shell.SpecialFolders("Favorites");
link = Shell.CreateShortcut(DesktopPath + "\\BBC.lnk");
link.Description = "html";
link.IconLocation = "C:\\WINNT\\system32\\url.dll";
link.TargetPath = "http://news.bbc.co.uk";
link.WindowStyle = 3;
link.WorkingDirectory = "c:\\winnt";
link.Save();

The next step for me is to check if any existing shortcuts in the favourites folder contain the same URL. If they do to delete/rename them.

The deleting/renaming is to ensure all users have exactly the same shortcut name for any given URL.

As always, any help will be greatly appreciated.


Radimus
(KiX Supporter)
2003-07-25 11:40 AM
Re: Adding IE Favourites

kix will do that just fine.

use enumdir() to get an array of all the filename.url in your favorite folder

code:
$folder=readvalue('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders','Favorites')
for each $file in enumdir($folder,'*.url',1)
if readprofilestring($file,'InternetShortcut','URL')=$MyOldURL
$=writeprofilestring($file,'InternetShortcut','URL',$MyNewURL)
endif
next



Sealeopard
(KiX Master)
2003-07-25 03:46 PM
Re: Adding IE Favourites

The reson why the codes most likely look overly complicated is that we normally write rather generic code with lots of error checks. However, the UDFs are all well tested, thus one only needs to copy them and use them according to their headers.

Sealeopard
(KiX Master)
2003-07-25 03:46 PM
Re: Adding IE Favourites

The reason why the codes most likely look overly complicated is that we normally write rather generic code with lots of error checks. However, the UDFs are all well tested, thus one only needs to copy them and use them according to their headers.

[ 25. July 2003, 16:32: Message edited by: sealeopard ]


Les
(KiX Master)
2003-07-25 04:09 PM
Re: Adding IE Favourites

I don't think newbies realize that UDFs should be just taken 'as-is' and do not require modification. They take one look at it, panic when the cannot understand all the logic, and hit the back button.