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

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.

Answers

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.
Answered 05/22/2011 by: MadForMsi
Blue Belt

Please log in to comment
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".
Answered 05/22/2011 by: an33th
Orange Belt

Please log in to comment
0
Dont forget that shortcuts have a file extension of .lnk.

P
Answered 05/23/2011 by: Inabus
Second Degree Green Belt

Please log in to comment
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.
Answered 05/23/2011 by: re_123
Senior Yellow Belt

Please log in to comment
Answer this question or Comment on this question for clarity