Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Is it possible to create folder-shortcuts that'll work on any computer

04 Jul 2015   #11
MilesAhead

Windows 7 32 bit
 
 

Another way to do it with Macro

Create the shortcut with relative path but instead of Explorer put GoShort.exe

It clears the address input line in the folder window and puts in the relative path via macro.

The exe should be put in a folder in the Path. The source is included so it could be changed to a hotkey implementation if desired.

The Sleep statements may be adjusted to control the macro speed.

To run or compile this script the latest ahk (currently 1.1.22.02) should be downloaded from here: AutoHotkey

Macro may look a bit clunky but if you adjust the wait times to fit your PC it is less noticeable.

Note: If you like it the way it is you do not need to download or have AHK installed. The exe has the AHK interpreter bundled inside.




Attached Files
File Type: zip GoShort.zip (377.3 KB, 1 views)
My System SpecsSystem Spec
.
04 Jul 2015   #12
GokAy

Windows 7 Ultimate x64 SP1
 
 

Ok, guys please see this: from the little testing I did, it works. It involves creating a single symbolic link (mklink /d):

Procedure is:
- copy my humble batch file inside your root folder (that you wish to carry around) and run it, you can change the folder name of course (it will create a symbolic directory link in root C to the folder it was run in, all PCs have a C as common, that's why I created the link here)
Code:
mklink /d C:\mainfolder %cd%
- (for ease of access) browse to C, and right click "mainfolder" and "Send To: Desktop"
- from this point on, only open your root folder with the shortcut on Desktop or from C:\mainfolder in order not to mess up shortcuts you will create anew (in Explorer if you click address bar, it will show C:\mainfolder\...)
- for old shortcuts, you have to edit them and replace a portion of it with "C:\mainfolder" such as:
-- replace "C:\Users\Gokhan\Desktop\New folder\...\..." (the bold part) in target box of the shortcut

- If you decide to move the folder to another place in same PC, then please delete the symbolic link in C before running the batch file again, as it doesn't overwrite/update the symbolic link, and I decided not to put a delete folder command in order to avoid any accidental data loss)

Once you setup the folder, you can move it to any place (run the bat file, and open the folder from C:\mainfolder or create a shortcut to desktop) and it will work.

Maybe one of you programmers can make a script/batch file/etc to change current shortcuts automatically?

Please try and comment on shortcomings and what not.


Attached Files
File Type: rar New folder.rar (2.1 KB, 3 views)
File Type: bat create_mklink.bat (28 Bytes, 2 views)
My System SpecsSystem Spec
04 Jul 2015   #13
MilesAhead

Windows 7 32 bit
 
 

With a hotkey implementation and macro you would not have to make links or shortcuts. Just text files with relative paths like this example

assuming you had a subfolder in the current folder named "download" the text file could be named anything but let us call it download_relpath.txt and it would have one line
.\download

the hotkey could read the selected file to get the relative path and paste it into the folder address input. Once the relative path is correct it would never need to be changed unless the folder layout was altered.

Many ways to skin the cat.

Edit: Yes you could double click the download folder instead. But it is just a foolproof example as proof of concept. ( Or you could have explorer settings such that a new window was opened if the actual folder was double clicked and this would move in the same window etc.. )
My System SpecsSystem Spec
.

04 Jul 2015   #14
GokAy

Windows 7 Ultimate x64 SP1
 
 

Miles, would you need to install AHK to all PCs that will be used? And does AHK have to be running for your method to work?

My methods strength (I believe):

- OP doesn't need to change his method

- Making a shortcut is faster, and once you create the link (1 click) and browse through C, every shortcut you create works on any PC, any partition, be it external or internal, you can even change the folder name and it will work, no need for 3rd party tools, which I believe is the best solution when possible.

- OP only needs to modify previously created shortcuts, unless someone comes up with a simple batch/script to do it automatically (I believe even this is redundant, with 1000 shortcuts need to be modified, it will take at most a day or two)

----------------------

To sum it up (once previous shortcuts are fixed):

- If there is a previous sym link, delete it (only if you need to change folder location)
- (Copy bat to folder, only for the first time) and run it
- make a shortcut of sym link to the desktop (optional but I would suggest to make life easier) and open explorer with that
- that's it!

----------------------
My System SpecsSystem Spec
04 Jul 2015   #15
MilesAhead

Windows 7 32 bit
 
 

So is the guy wrong that wrote the Relative utility that if the entire folder tree was copied to another machine the target would be copied rather than the symlink?

I don't know. I used links in Linux where there were no drive letters to get in the way of them working logically. Everything descended from '/' and that was that.

It is just as easy to make a macro that makes a text file with the relative path as it is to have it make a symlink. It is trivial.

Edit: The exe program does not need ahk to run. To modify the source and run or compile it, ahk is needed. Once you finalize the exe it runs on its own, Just copy to a folder in the Path.
My System SpecsSystem Spec
04 Jul 2015   #16
GokAy

Windows 7 Ultimate x64 SP1
 
 

Quote:
would you need to install AHK to all PCs that will be used? And does AHK have to be running for your method to work?
These were genuine questions, and I asked you because I know you are proficient with AHK and use it to write some of your programs. You are the guy I will be seeking help from if I ever need AHK (And UsernameIssues for AutoIt)

Using relative paths for Windows shortcuts - Super User, this method would work for the OP of that thread too.

As for Relative's webpage, here is the part about sym links (notice he is talking about usage of links which reside in the folders themselves, I don't have any links within the folder, all are pure shortcuts):

Quote:
What's wrong with "mklink"? Unfortunately, at least two big things:

1- If you copy symbolic links with Explorer or a directory tree that contains such links, the link files that should be in the copy are replaced by their targets! This is a fatal design flaw.

2- If you backup Windows machines with a remote linux file server, symbolic links are copied as zero-length files with no information about how to recreate them when the backup is restored. Of course, that's just a limitation of Samba on Linux. So next I tried using Microsoft's backup program that comes with Windows 7. I created a small tree of files and folders that contained some symbolic links and backed them up. Then I restored the backup to another location. The result was such a mess that I'm at a loss for words to describe it.
1- There is no symbolic link copying involved. You only copy your working folder, which includes normal shortcuts, re-running the batch file (no configuration needed as it uses %cd%) at the new location creates a new sym link at C.

2- No need to backup the sym link, you can backup your working folder as you see fit with whatever program you wish to use, again just re-run the batch file after you restore and the shortcuts will start to work.

I really appreciate your input (especially in your holiday ), hopefully others will chime in too.
My System SpecsSystem Spec
05 Jul 2015   #17
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

Symbolic Links are basically Shortcuts but include support for relative paths as targets. They're a feature built into Windows and do not require a 3rd party program to create.

Quote   Quote: Originally Posted by GokAy View Post
[insert post 12 and 14 here]
GokAy, I think you may have missed a few points. Please see my post #7 where I establish the fact that Shortcut files, per se, do not support relative paths as targets, which is what the OP really needs. Designing some Shortcut with relative path capability is the real goal here.

Now revise your post #12. The method you describe, GokAy, which I'll summarise here (extremely briefly) --
Quote:
constantly rebuild each of one's (absolute path-ed) Symbolic Links when needed, using a Batch file
... does not make any sense. Why not simply create a Symbolic Link with a relative path target in the first place?


The OP ultimately has two options here:
a) Format his thumb drive to NTFS and use Symbolic Links (that use relative paths),
OR
b) Choose not to format his thumb drive to NTFS, and instead use MilesAheads' method of creating relative Shortcuts.
(Windows' variant of Symbolic Links are, of course, an exclusive feature of the New Technology File System, and can only be used on NTFS formatted devices)

... OR (not recommended)
c) (see below script)


Quote   Quote: Originally Posted by MilesAhead View Post
If the entire folder tree was just below the root drive letter you might be able to get away with running a small program to change all the drive letters in the paths in the shortcuts. [...] Any small scripting language with a function to read and write shortcuts could do it.
Quote   Quote: Originally Posted by GokAy View Post
OP only needs to modify previously created shortcuts, unless someone comes up with a simple batch/script to do it automatically (I believe even this is redundant, with 1000 shortcuts need to be modified, it will take at most a day or two)
No, the OP does not need to modify his Shortcuts. The OP needs to use some method or form of relative Shortcuts.


If you guys insist you must see such a script, then here ...
Code:
// th-374447.js

/* desc.
For each Shortcut (.lnk) file in the script's directory and all child 
directories, modify the Shortcut's target path to use a drive letter 
the same as this script's current location (when it's run). 
*/

var fso = new ActiveXObject('Scripting.FileSystemObject')
var WshShell = new ActiveXObject('WScript.Shell')

drive_letter = fso.GetDriveName(WScript.ScriptFullName)

function recurse_folders( folder ) {
	for (var enum_file = new Enumerator(folder.files); !(enum_file.atEnd()); enum_file.moveNext()) {
		if ( fso.GetExtensionName(enum_file.item().path).toUpperCase() == 'LNK' ) {
			lnkfile = WshShell.CreateShortcut(enum_file.item().path)
			lnkfile.TargetPath = fso.GetDriveName(WScript.ScriptFullName) + lnkfile.TargetPath.slice(drive_letter.length)
			lnkfile.Save()
			delete lnkfile
		}
	}
	delete enum_file
	for (var enum_subfolder = new Enumerator(folder.subfolders); !(enum_subfolder.atEnd()); enum_subfolder.moveNext()) {
		recurse_folders(enum_subfolder.item())
	}
	delete enum_subfolder
}
recurse_folders( fso.GetFolder(fso.GetParentFolderName(WScript.ScriptFullName)) )
(it takes about 25 seconds to process 1000 Shortcut files with my laptop (using a thumb drive with absolutely nothing on it but Shortcuts (and the script file of course (don't forget the script file or it won't work (I tried it myself (didn't work without the script file (strange)))))))

c) Choose not to format his thumb drive to NTFS, and instead use a script to edit each of his Shortcut files' target paths to use the appropriate drive letter for it's current volume.


Don't consider the above as a solution though. I, for one, do not want to have to click on some script each time I want to use my USB.

As far as relative Shortcuts go, Symbolic Links deliver the best fit user experience. Set it up once, no more clicking.
My System SpecsSystem Spec
05 Jul 2015   #18
MilesAhead

Windows 7 32 bit
 
 

Quote   Quote: Originally Posted by GokAy View Post
As for Relative's webpage, here is the part about sym links (notice he is talking about usage of links which reside in the folders themselves, I don't have any links within the folder, all are pure shortcuts):
This is what confused me. The mixing of shortcuts and links so I don't know who is talking about what method. In any case I think the OP should comment on what seems good for the purpose. If macros seem like a kludge there is no sense writing more.

We need feedback rather than arguing which is best among alternatives nobody will use(or where that is at least a strong possibility.)
My System SpecsSystem Spec
Reply

 Is it possible to create folder-shortcuts that'll work on any computer




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Sound Shortcuts - Create
How to Create Sound Shortcuts in Windows 7 and Windows 8 This tutorial will show you how to create or download shortcuts that open directly to the Playback, Recording, Sounds, and Communications tabs in the Sound control panel in Windows 7 and Windows 8. EXAMPLE: Sound NOTE: Opened to...
Tutorials
Mouse Properties Shortcuts - Create
How to Create "Mouse Properties" Shortcuts in Vista, Windows 7, and Windows 8 This will show you how to create or download Mouse Properties shortcuts that open to the Buttons, Pointers, Pointer Options, Wheel, and Hardware tabs in Mouse Properties. What you have displayed for the tabs...
Tutorials
Would like to create Internet shortcuts with appropriate favicon
I keep my Internet shortcuts in folders and would like to be able to maintain the original favicon (that would otherwise be in Favorites). Please tell me how to do this. All I usually get is the IE or Firefox favicon.
Browsers & Mail
How to create web page shortcuts?
Hi! Please tell me how do i create a desktop shortcuts for web pages. I want create Facebook and gmail, etc web pages desktop shortcuts, so how do i do it? I downloaded "iconomize_facebook_desktop_icon_installer" but after install it nothing happen, there's no shortcut for start that program. So...
Browsers & Mail
Cannot create/delete shortcuts in any folder in windows 7
Hi all, I have a weired issue with shortcuts handling in windows 7. Immediate after I login to Windows 7 and for less than a minitue I'm able to delete/create a shortcut, but after a minute or so the functionlaity gets disabled in all folders. I get access denied message everytime I try to...
General Discussion
Cannot create new folder / changing reg doesn't work
Hi, not sure where this should go so I'm putting it here. I can't create new folders through explorer through clicking the "new folder" button and the option is also missing from the right-click menu. I've tried the registry fix, but no can do. Any ideas? Thankies :)
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 15:34.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App