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
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)
Please log in to answer
Posted by:
AngelD
18 years ago
Posted by:
DevGowda
18 years ago
Posted by:
DevGowda
18 years ago
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
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.
so that the conversation will remain readable.