I want to create desktop shortcut for " and use c:\cnn.ico file. How to write a script?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
'Four parameters surlshortcutname, stargetpath, iconindex, iconfile
surlshortcutname="cnn" 'without extension
stargetpath="[URL unfurl="true"]http://www.cnn.com"[/URL]
'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=0
iconfile="c:\cnn.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