@Markus:
I've used your "Get UNC path from file path" script for some while now on Windows 7, but I had to change it a bit to work for me (part of it could be because it's a Windows 7 machine).
First, I had to change the for-loop a bit so it correctly finds the remotename of the machine, this could be because of a different output format in Windows 7 net use, but I haven't checked it against a Windows XP or Vista machine... anyway, this way it works with Windows 7 64 bit net use now.
Secondly I built an "if" clause into it so it checks if it's really a network path and if it's not a network path it will retain the drive letter at the beginning of the path.
Thirdly I used "setlocal enabledelayedexpansion" and the delayed expansion syntax in some parts so a bracket in the path doesn't screw up the whole thing
And fourthly I put the resulting path into the clipboard with the "clip.exe" program available in Windows 7.
Then I put it in my Program Folder and added the following keys/values to the registry so I can choose from the context menu of a folder or file the entry "Get UNC Path" and the local- or unc-path of the file or directory get copied in my clipboard.
HKEY_CLASSES_ROOT\*\shell\unc
@="Get UNC Path"
HKEY_CLASSES_ROOT\*\shell\unc\command
@="\"C:\\Program Files\\Batch\\getunc.bat\" \"%1\""
HKEY_CLASSES_ROOT\Directory\shell\unc
@="Get UNC Path"
HKEY_CLASSES_ROOT\Directory\shell\unc\command
@="\"C:\\Program Files\\Batch\\getunc.bat\" \"%1\""
This is great if you need to send the correct path by email within a company and you might not know if they have set the network directory to the same letter as you. So you can just use "Get UNC Path" from the context menu and paste the correct path into your e-mail. At least that's one way how I use it ;)
Markus has tested the version I suggested using \\ now in multiple languages:
You're right, the difference isn't the OS but the language. The new version searching for "\\" instead of "Remote" works very fine! I've installed a few other language packages and tested the net use command with them. Turns out the more complex languages (chinese, ...) and some of the smaller ones (estonian) just use the english text, other languages use their own text but the new version should work for them all.
The position would be 19 in german too, but while checking other languages I found out that in other languages the position of the beginning of the unc path varies.
Here is the "Remote name" line in different languages:
english:
Remote name \\server\subfolder
german:
Remotename \\server\subfolder
hungarian
Távoli név \\server\subfolder
finnish:
Etänimi \\server\subfolder
frensh:
Nom distant \\server\subfolder
italian:
Nome remoto \\server\subfolder
polish:
Nazwa zdalna \\server\subfolder
turkish:
Uzak ad \\server\subfolder
But once again, the new version searching for "\\" should work fine in every language, it certainly works for me :) many thanks! |