0

I often need to create or edit a shortcut (a .lnk file) for an other computer. Of course the path that is defined in these shortcuts is not always valid for my computer since I don't have the same permissions or the same application installed on my PC.

Example of the error: Problem with Shortcut

How can I make Windows shut up, ignore this and let me edit shortcuts?

2

Yes, we can make invalid links through VBScript.

Sub Shortcut(Application,Name,Location,Icon,Hotkey)
  Dim objShell,DesktopPath,objShortCut,MyTab
  Set objShell = CreateObject("WScript.Shell")
  MyTab = Split(Application,"\")
  If Name = "" Then
    Name = MyTab(UBound(MyTab))
  End if
  Set objShortCut = objShell.CreateShortcut(DblQuote(Location & "\" & Name & ".lnk"))
  objShortCut.TargetPath = DblQuote(Application)
  ObjShortCut.IconLocation = Icon
  ObjShortCut.Hotkey = Hotkey
  objShortCut.Save
End Sub
Sub DblQuote(Str)
  DblQuote = Chr(34) & Str & Chr(34)
End Sub

And Call in script like:

Call Shortcut("C:\InvalidDestination","Invalid Shortcut","C:\","shell32.dll,47","CTRL+ALT+N")
2

I modified the answer by @Wasif Hasan

Create a new text file with the extension .vbs (e.g. C:\Temp\createShortcut.vbs) and paste the following code snippet:

Sub CreateShortcut(Application, arguments, Name, OutputFolder, Icon, Hotkey)
    If arguments <> "" Then arguments = " " & arguments

    With CreateObject("Wscript.Shell").CreateShortcut(OutputFolder & "\" & Name & ".lnk")
        .TargetPath = Application
        .arguments = arguments
        .WorkingDirectory = Left(Application, InStrRev(Application, "\"))
        .IconLocation = Icon
        .Hotkey = Hotkey
        .Save
    End With
End Sub

Dim Application, arguments, Name, OutputFolder, Icon, Hotkey

Application = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
arguments = "http://www.google.com"
Name = "Shortcut to Google"
OutputFolder = "C:\Temp\"
Icon = "shell32.dll,47"
Hotkey = "CTRL+ALT+N"

Call CreateShortcut( Application, arguments, Name, OutputFolder, Icon, Hotkey)

Edit the arguments:

Application, arguments , Name, OutputFolder , Icon , Hotkey

Then save.

Open CMD and run wscript "C:\Temp\createShortcut.vbs"

0

Windows 10 will not let you edit / make an invalid link.

Make a folder c:\temp and copy the Link file to c:\temp. Now see if you can edit it there. You would need an editor like Ultra Edit or such like. Even in c:\temp the link wants to open normally.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.