Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

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
share|improve this answer
    
Thanks. This worked perfectly. –  Alistair McMillan Aug 23 '10 at 12:53
    
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 '12 at 20:57
1  
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 '12 at 8:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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