5

Trying to create a shortcut for someone else. It needs to point to files on one of their mapped drives. Instead of waiting for them to be available and create the shortcut on their PC, I was hoping to just create the shortcut on my PC and then transfer it over to their PC.

However Windows tries to validate the path as you create the shortcut and since I don't have access to the same files it is throwing up an error and won't create the shortcut.

Is there a way to create a shortcut without the path being validated?

1 Answer 1

8

You can use this VBScript to create a shortuct:

   Set oWS = WScript.CreateObject("WScript.Shell")
   sLinkFile = "C:\MyShortcut.LNK"
   Set oLink = oWS.CreateShortcut(sLinkFile)
   oLink.TargetPath = "C:\Program Files\MyApp\MyProgram.EXE"
   oLink.Save
2
  • Actually Massimo, this doesn't solve his problem. Windows will still validate that c:\program files\myapp\myprogram.exe exists before creating the shortcut. Worse yet, if the TargetPath is a network share that is unavailable, say \\\192.168.0.123\share, then Windows waits up to about 30 seconds before it fails!!! One could create the .LNK file manually without using WScript.CreateShortcut() and that would solve it. But you would need to be sure the .LNK file format is correct. I am still searching for a good solution to this problem.
    – user134834
    Sep 5, 2012 at 20:57
  • 3
    This is not my experience. I just tried running the script on a Windows 7 system, pointing it to a non-existing file (the exact same path you see in the example above), and it created the shortcut without any error. I opened the shortcut's properties thereafter, and it indeed pointed to the given path. Double-clicking it produced the expected result: Explorer complained about the missing shortcut target.
    – Massimo
    Sep 6, 2012 at 8:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .