QUESTION :
I would like to create a shortcut, the target of which does not exist (yet). However, as soon as I try to create it, Windows raises an error saying the specified target does not exist.
While I understand why Windows raises this error, I would like to know if there is a way to bypass it.
My file will be located on D:MyScript.exe
, so creating a fake file with this name will not work, since the character is forbidden for Windows filenames.
ANSWER :
Shortcut from Optimumx can create shortcuts to non-existing targets.
You will probably run the following command
shortcut /F:example.lnk /A:C /T:D:MyScript.exe
Sources:
1. Create a Shortcut to a non-existing folder in Windows XP
2. http://www.msfn.org/board/topic/70537-is-there-a-way-to-create-a-shortcut-without-the-source-file/
IMO, there is only 1 way, and that is a simple hack.
Create a new file (like a text file), call it the eventual file name with the extension. Of course this file won’t work, but Windows will reference it. Then, when you have the real file, just copy it over the top of your dummy file!
As Dave mentioned you can create a file as a placeholder, that matches the shortcut rule. If its on another drive (like D: as you mentioned) then map a drive to that drive letter (right click my computer >> map a drive >> \[your hostname]c$temp
). If its in a directory you dont have access to, create the shortcut on a different computer where you do, then copy it over.
Here is a script I wrote up combining some other peoples ideas to create a shortcut to a folder even if it does not exist. It makes the folder then deletes the folder. Copy the below text to a .cmd file and run it. The only thing you should need to edit is the variables DIR and NAME. If you are creating a file shortcut, make sure to comment out the mkdir %DIR%” line.
@ECHO OFF
REM This script creates a shortcut to a folder and places it on your Desktop.ECHO Setting Target Path...
set DIR="C:Folder_Path"ECHO Setting Name of shortcut
set NAME=Shortcut_NameECHO Creating Temporary Directory for Shortcut to match to...
REM If you are creating a file shortcut, comment out this mkdir line to avoid making a folder shortcut.
mkdir %DIR%ECHO Running Creating VB Script...
REM This is where the temporary VBS file will be located.
set VBS=%USERPROFILE%DesktopCreate-Icon.vbs
>> %VBS% echo Dim FileName, UploadStac
>> %VBS% echo UploadStac ="Stac Upload"
>> %VBS% echo FileName = "%NAME%"
>> %VBS% echo Set shortcut = CreateObject("WScript.Shell").CreateShortcut(CreateObject("WScript.Shell").SpecialFolders("Desktop") ^& + "" + FileName + "".lnk"")