I use windows 7 SDK sample code to create and install a virtual folder on windows 7. It is not a real file system, it just a COM object which tells the windows explorer what should display, Like following: enter image description here

Now I want to create a shortcut for this virtual folder "Jerry" from the command line. I follow the instructions from this question: How to make a shortcut from CMD? and create the script:

@echo off
echo Set oWS = WScript.CreateObject("WScript.Shell") > CreateShortcut.vbs
echo sLinkFile = "%UserProfile%\\Links\\test.lnk" >> CreateShortcut.vbs
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> CreateShortcut.vbs
echo oLink.TargetPath = "Computer\Jerry" >> CreateShortcut.vbs
echo oLink.Save >> CreateShortcut.vbs
cscript CreateShortcut.vbs
del CreateShortcut.vbs

After run it, it only creates this one:

enter image description here

But if I just simply drag the virtual folder "jerry" from the explorer to the tree view of "Favoriates", it can create the shortcut normally: enter image description here

And right-click the virtual folder to create the shortcut also works: enter image description here

So how could I create the shortcut for the virtual folder from the command line ?

  • I don’t believe you will be able to. Windows shortcuts are partially a function of the file system itself and as you point out what you have made isn’t an actual file system. In addition Windows shortcuts are limited to file systems it can read which as you point out what you created isn’t a file system – Ramhound Oct 27 '17 at 0:25
  • @Ramhound But I can right click the virtual folder and then click "Create Shortcut". This way works well. – beasone Oct 27 '17 at 0:28

Your Answer

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

Browse other questions tagged or ask your own question.