Make a shortcut to cmd. Then set the cwd in the shortcut properties. Follow these steps: Make a new shortcut to: cmd. Now right-click on it and get properties of the shortcut shortcut tab. Set the "Start in" directory i. The standard folder icon will probably be in the lower right-hand corner.
Now you can copy this file and just change the "Start in:" directory to make new relative shortcuts. NOTE: The above steps are just an example hence try this at your own risk. And check if it works. Visit our Microsoft Answers Feedback Forum and let us know what you think. Depending on the version of Windows the shortcut resides, the icon will will sometimes change accordingly.
See Using the "start" command with parameters passed to the started program to better understand the empty double-quotes at the beginning of the first Target command. According to Microsoft, if you leave the 'Start In' box empty, the script will run in the current working directory.
I've tried this in Windows 7 and it appears to work just fine. Try using Relative a Windows command-line application. Here is a small primer. You can either set this value via a batch file, or you can probably set it programmatically if you share how you're planning to create your shortcut. I'm not sure if I'm right, or I'm missing something, but as for now , running Win7 Enterprise SP1 a LNK file adapts itself on moving or even changing the drive letter after it is run at a new place!
I created a new shortcut on my USB drive and tried moving the shortcut and its target in a way that the relative position stayed unchanged, then I changed the drive letter. The shortcut worked in both cases and the target field was adapted after I double-clicked it. You can make a relative shortcut manually by changing the file path. After reading several answers, I decided to do it with a simple solution: Instead of a shortcut, I made a.
I like leoj3n's solution. Unfortunately, according to the lnk file specification , the icon is not saved in the shortcut, but rather "encoded using environment variables, which makes it possible to find the icon across machines where the locations vary but are expressed using environment variables. The link with a relative path can be created using the mklink command on windows command line.
This might be the best way to create link because apparently, the behaviour of shortcut can be different perhaps based on the way they are created UI vs mklink command. I observed some strange behavior with how the shortcuts behave when I change the root folder. For demonstration purposes call our app "test. Easy way is using self-extraction zip file, neatly packaged as an ".
There is ways to make one self-extraction zip file that extracts different files to different directories, but i haven't played with it yet. Another way is to make a selfextract for the shorcut, embed it inside the selfextract for the app and then apply a run once script,being that you know where the file is going to be. That will make the console window disappear, but everything else remains the same. Make a symbolic link of a relative path.
On the command prompt cmd with Administrator privileges :. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Making a Windows shortcut start relative to where the folder is? Ask Question. Asked 12 years, 5 months ago. Active 25 days ago. Viewed k times. Peter Mortensen William William 8, 23 23 gold badges 73 73 silver badges bronze badges. If somebody else installs the game, will that affect the existing shortcut?
Will they be installing to a completely different folder, but it will still break the existing link? Add a comment. Active Oldest Votes. On Windows 7 you will get bat - Shortcut in the current directory.
On Windows XP you will get Shortcut to bat. But the answer already showed such an example. So please re-state the point you were making? Your answer aims to the case where the target is an executable file. The OP is interested in shortcuts to folders. Please check if your answer addresses the case, and post an explicit example for that.
Kevin Panko 7, 22 22 gold badges 42 42 silver badges 52 52 bronze badges. Hrvoje Golcic Hrvoje Golcic 1 1 silver badge 4 4 bronze badges. Flyingfenix 3 3 bronze badges. Krauss Krauss 1 1 silver badge 4 4 bronze badges.
But will that link still be correct, if the set of folders is moved to a different location? This requires privileges I do not have, although it looks like it would do the job Would you mind posting an image of the resulting Shortcut properties, once it was created? The links are indeed correct. That can be confirmed with the "dir" command. The problem is that "copy-paste", "move" and "copy" actions of the File Manager will destroy the structure.
I have modified the answer to include a workaround. It would also be helpful to add an explicit warning of what exactly will happen if you were to e. In this case, there should be no difference. Community Bot 1. David d C e Freitas David d C e Freitas 4, 3 3 gold badges 24 24 silver badges 32 32 bronze badges. How does this help OP's goal of navigating Windows Explorer to a specified folder?
If you had the problem then the solution makes sense Your assertion that "leav[ing] the 'Start In' box empty The empty "start in" instead solve this problem in any file manager because the link is followed into the Total Commander panel.. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog.
Podcast Making Agile work for data science. Stack Gives Back Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Linked 2. Related 8. Hot Network Questions. Question feed.
0コメント