Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to rename a shortcut

Status
Not open for further replies.

lorri

Technical User
Oct 4, 2006
61
0
0
US
Hi All - what is the syntax to rename a shortcut on your desktop? help is apprecaited

Thank
-L
 
I would think the same as changing any other file name...

i.e.

Code:
Option Explicit

Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objFile : Set objFile = objFSO.GetFile("C:\temp\SomeShortcut.lnk")
objFile.Name = "SomeShortcut_Renamed.lnk"

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
so where do I fit this in?
Set objFileSys = CreateObject("Scripting.Filesystemobject")
Set objShell = WScript.CreateObject("WScript.Shell")
strStartMenu = objShell.SpecialFolders("AllUsersStartMenu")


If Not objFileSys.FileExists("c:\Program Files\Microsoft Office\OFFICE11\OIS.EXE") Then wscript.quit(1)
If Not objFileSys.FileExists(strStartMenu & "\Microsoft Picture Manager.lnk") Then
Set objShortcut = objShell.CreateShortcut(strStartMenu & "\Microsoft Picture Manager.lnk")
objShortcut.TargetPath = "c:\Program Files\Microsoft Office\OFFICE11\OIS.EXE"
objShortcut.WindowStyle = 1
objShortcut.IconLocation = "c:\Program Files\Microsoft Office\OFFICE11\OIS.EXE, 0"
objShortcut.WorkingDirectory = "c:\Program Files\Microsoft Office\OFFICE11\"
objShortcut.Save
End If


Set objFileSys = Nothing
Set objShell = Nothing
wscript.quit(0)
 
It looks like you're creating the shortcut with the code you posted...just name it what it should be. If there already exists a shortcut with a different name and you know what it is...then use the code I previously posted.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top