/build/static/layout/Breadcrumb_cap_w.png

vbscript to rename a shortcut

Hi,

I need a vbscript to remove the file extension from the shortcutname.

for eg, readme.txt - the extn .txt need to be removed.

i tried with the below script,it removes the file extension but while launching the file again it browses for the file again.

Option Explicit
Dim objShell, objFSO, strAllUsersProfile
Set objShell = CreateObject("Wscript.shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strAllUsersProfile = objShell.ExpandEnvironmentStrings("%ProgramData%")
If objFSO.FileExists(trim(strAllUsersProfile & "\Microsoft\Windows\Start Menu\Programs\test\New Text Document.txt")) then
objFSO.MoveFile strAllUsersProfile & "\Microsoft\Windows\Start Menu\Programs\test\New Text Document.txt", strAllUsersProfile & "\Start Menu\Programs\test\New Text Document"
End If
Set objShell = Nothing
Set objFSO = Nothing

0 Comments   [ + ] Show comments

Answers (4)

Posted by: MadForMsi 13 years ago
Blue Belt
0
keeping extension in shortcutname will not affect app functionality. Script which you have written looks ok, and you also said it works, so problem is somewhere else.
Posted by: an33th 13 years ago
Orange Belt
0
Option Explicit
Dim objShell, objFSO, strAllUsersProfile
Set objShell = CreateObject("Wscript.shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strAllUsersProfile = objShell.ExpandEnvironmentStrings("%ProgramData%")
If objFSO.FileExists(trim(strAllUsersProfile & "\Microsoft\Windows\Start Menu\Programs\test\New Text Document.txt")) then
objFSO.MoveFile strAllUsersProfile & "\Microsoft\Windows\Start Menu\Programs\test\New Text Document.txt", strAllUsersProfile & "\Start Menu\Programs\test\New Text Document"
End If
Set objShell = Nothing
Set objFSO = Nothing


What you are doing here is renaming a file put in a location meant for application shortcuts and you are doing that well using your script!

Files without extension would actually look out for program using which it should execute. Only a shortcut file would look out for the target file location.

Files with .lnk extension are shortcuts. If your shortcut does display the file extension then the name of the shortcut might be "New Text Document.txt.lnk" and you might want to rename it to "New Text Document.lnk".
Posted by: Inabus 13 years ago
Second Degree Green Belt
0
Dont forget that shortcuts have a file extension of .lnk.

P
Posted by: re_123 13 years ago
Senior Yellow Belt
0
As it is a shortcut file installed by the Vendor MSI, if we remove the extn, it was not working.Finally, i deleted the files and created a command line argument shortcut.it worked fine. :)

Thanks.
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