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
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)
Please log in to answer
Posted by:
MadForMsi
13 years ago
Posted by:
an33th
13 years ago
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:
re_123
13 years ago
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.