Share via

Using NotePad

Anonymous
2010-09-29T14:46:58+00:00

I have a folder containing shortcuts to a variety of file on various drives.  The shortcuts are all .lnk files.

I need to edit some of the shortcuts.  If I right-click the shortcut and select Open With NotePad, Windows attempts to open the destination file rather than the shortcut itself.

My current workaround is to open the shortcut'sProperties and edit the path there.  If I can get NotePad to open the .lnk, then I can write a script to automate the process.


gsnu201005

Windows for home | Previous Windows versions | Apps

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2010-09-29T19:38:33+00:00

I would hesitate to use Notepad to edit any shortcut as its text capabilities simply will not handle the binary and unicode entries within a .LNK shortcut.

If you are going to write a script, then perhaps writing a proper .VBS script would be the way to go. The following snippet enumerates a folder called C:\Shortcuts for .LNK files and displays their filenames and shortcut target paths. Any file with out an .LNK extension is displayed within brackets. I'm supplying this simple code snippet so you can get an idea of the VBS scripting capabilities. You were not very specific on what you intended to do with the shortcut beyond a path edit. A VBSReplace command should be able to handle general editing like that.

objStartFolder = "C:\Shortcuts"

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFolder = objFSO.GetFolder(objStartFolder)

Set colFiles = objFolder.Files

For Each objFile in colFiles

   If Right(objFile.Name, 4) = ".lnk" Then

      Set sh = CreateObject("WScript.Shell") 

      Set shortcut = sh.CreateShortcut(objStartFolder & "" & objFile.Name) 

      Wscript.Echo objFile.Name & Chr(10) & shortcut.TargetPath

      shortcut.Save 

   Else

      Wscript.Echo "(" & objFile.Name & ")"

   End If

Next

To run this simply copy the code into a blank Notepad text file and save it as*<something>*.vbs. Edit the C:\Shortcuts entry for your own purposes. Double click to run it or from a command line. For more information see,

CreateShortcut Method

http://msdn.microsoft.com/en-us/library/xsy6k3ys(v=vs.85).aspx


  • If this proposed solution has resolved your issue(s), please return and mark it as Answered for others to consider.

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2010-09-29T23:36:20+00:00

    Thanks!


    gsnu201005

    Was this answer helpful?

    0 comments No comments