/build/static/layout/Breadcrumb_cap_w.png

Shortcut deletion and creation script

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   [ + ] Show comments

Answers (4)

Posted by: AngelD 17 years ago
Red Belt
0
How about change fso.deletefile strdesktop & "\Citrix Program Neighborhood" to fso.deletefile strdesktop & "\Citrix Program Neighborhood.lnk"
Posted by: DevGowda 17 years ago
Orange Belt
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
Posted by: AngelD 17 years ago
Red Belt
0
Try use the shortname (CITRIX~1.LNK) instead.
Posted by: DevGowda 17 years ago
Orange Belt
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
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ