/bundles/itninjaweb/img/Breadcrumb_cap_w.png
Hi All,

I am trying to delete a shortcut present on the desktop and place a new shortcut in place of that which points to a URL and has a different shortcut Name. But i am getting error while deleteing the shortcut present on the desktop. It says file not found. Can anyone out here help me through this script????????



Set WshShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

RootPath = WshShell.ExpandEnvironmentStrings("%SYSTEMDRIVE%")

strProgramFiles = Rootpath & "\Program Files\Citrix\ICA Client"

strDesktop = WshShell.SpecialFolders("Desktop")
Set sPath = fso.GetFolder(strDesktop)

fso.deletefile strdesktop & "\Citrix Program Neighborhood"

ShortCutName="Citrix"
Set objShortcutLnk = WshShell.CreateShortcut(sPath & "\" & ShortCutName &".lnk")

TargetPath = "https://myapps.int.corp.sun"

objShortcutLnk.TargetPath = TargetPath

objShortcutLnk.IconLocation = strProgramFiles & "\cpviewer.exe, 0"

objShortcutLnk.Hotkey = ""

objShortcutLnk.Save

Thanks in Advance
Dev
0 Comments   [ - ] Hide Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
Answer this question or Comment on this question for clarity

Answers

0
How about change fso.deletefile strdesktop & "\Citrix Program Neighborhood" to fso.deletefile strdesktop & "\Citrix Program Neighborhood.lnk"
Answered 08/25/2006 by: AngelD
Red Belt

Please log in to comment
0
Yeah... I have tried that as well.....
When I run the script it simply says file not found or bad file name. I am able to create a new shortcut but not able to delete the old shortcut.

thanks
Answered 08/27/2006 by: DevGowda
Orange Belt

Please log in to comment
0
Try use the shortname (CITRIX~1.LNK) instead.
Answered 08/28/2006 by: AngelD
Red Belt

Please log in to comment
0
Hi AngelD,

Thanks for ur suggestions....
I got the script to work.... I modified little code in the script and it worked. the problem was with the " "(Quotes). The below code works Greatly.

option explicit
on error resume next

Dim WshShell,fso
Dim RootPath, strProgramFiles, strDesktop, sPath, AllUsersDesktop
Dim ShortCutName, objShortcutLnk, TargetPath

Set WshShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

RootPath = WshShell.ExpandEnvironmentStrings("%SYSTEMDRIVE%")
strProgramFiles = Rootpath & "\Program Files\Citrix\ICA Client"

strDesktop = WshShell.SpecialFolders(AllUsersDesktop)

if fso.fileExists(strDesktop & "\Citrix Program Neighborhood.lnk2") then
fso.deletefile(strDesktop & "\Citrix Program Neighborhood.lnk2")
end if

Set sPath = fso.GetFolder(strDesktop)

ShortCutName="Citrix"
Set objShortcutLnk = WshShell.CreateShortcut(sPath & "\" & ShortCutName &".lnk")

TargetPath = "https://xxxxxxxx"

objShortcutLnk.TargetPath = TargetPath

objShortcutLnk.IconLocation = strProgramFiles & "\cpviewer.exe, 0"

objShortcutLnk.Hotkey = ""

objShortcutLnk.Save

Thanks
Dev
Answered 08/28/2006 by: DevGowda
Orange Belt

Please log in to comment