'Four parameters surlshortcutname, stargetpath, iconindex, iconfile

surlshortcutname="NcompassTrack Site Login"    'without extension
stargetpath="http://www.ncompassmkt.com/login.aspx"

'To use default, set these 2 variables to null (either one will do)
'If use existing setting, set them to empty string or comment them out (either one will do)

iconindex=1
iconfile="c:\Users\Dave\Desktop\ncmain1.ico"

set wshshell=createobject("wscript.shell")
sDesktop=wshshell.specialfolders("Desktop")
set ourllink=wshshell.createshortcut(sDesktop & "\" & surlshortcutname & ".url")
ourllink.targetpath=stargetpath
ourllink.save

surllinkfile=ourllink.fullname
set ourllink=nothing : set wshshell=nothing

if isempty(iconindex) or isempty(iconfile) then
    wscript.quit (0)    'existing urllink, if any, settings, are preserved
end if

set fso=createobject("scripting.filesystemobject")
set f=fso.getfile(surllinkfile)
set ots=f.openastextstream(1)
contents=""
do while not ots.atEndofstream
    line=ots.readline
    if instr(1,line,"IconIndex",1)=0 and instr(1,line,"IconFile",1)=0 then
        contents=contents & line & vbcrlf
    end if
loop
ots.close

if not (isnull(iconindex) or isnull(iconfile)) then
    if not (isempty(iconindex) or isempty(iconfile)) then
        contents=contents &"IconIndex=" & cstr(iconindex) & vbcrlf
        contents=contents & "IconFile=" & iconfile
    end if
end if
set ots=f.openastextstream(2)
ots.write contents
ots.close
set ots=nothing : set f=nothing : set fso=nothing