Sign in to follow this  
Followers 0
pdaughe

Shortcuts and UNC paths -- Advice needed

9 posts in this topic

Hi,

It's always easier to advise someone when you know what they're trying to do, so I'll try to briefly explain:

Two computers: A and B.

On computer B, a script creates a folder of shortcuts to files on computer B.

The folder (containing the shortcuts) is shared on the home network.

In order for computer A to successfully access the shortcut files in the folder, the shortcut targets must be UNC paths.

Instead of:

C:\Documents and Settings\UserName\My Documents\My Music\Artist\Song.mp3

use:

\\FamilyComputer\My Documents\My Music\Artist\Song.mp3

My question is: How can the script which runs on computer B best determine what the UNC path name (as seen from computer A) would be for the shortcut target?

I searched the forums and found lots of information w.r.t. DriveMap, but note that no drives are mapped (or need to be mapped) between the two computers.

One post referred to WnetGetUniversalName, but that was over my head.

Your advice would be greatly appreciated.

Sincerely,

Paul

Share this post


Link to post
Share on other sites



Can you just use

ShellExecute("\\FamilyComputer\My Documents\My Music\Artist\Song.mp3")
?

or you need to create a shortcut?

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Can you just use

ShellExecute("\\FamilyComputer\My Documents\My Music\Artist\Song.mp3")
?

or you need to create a shortcut?

Thanks -- the goal is for computer A to read the shared folder that contains the shortcuts. No problem with that, but the shortcut TARGET has to be a UNC path name. Once you have the UNC path name (on computer A), computer A could then do the ShellExecute or whatever. Edited by pdaughe

Share this post


Link to post
Share on other sites

I see what you want to do now... :whistle:

If you are not concerned about the the secruity, easiest way is share out the root folder.

Then if your shortcut says "C:\Documents and Settings\UserName\My Documents\My Music\Artist\Song.mp3"

replaace with "\\Computer A\C$\Documents and Settings\UserName\My Documents\My Music\Artist\Song.mp3"

Share this post


Link to post
Share on other sites

I see what you want to do now... :whistle:

If you are not concerned about the the secruity, easiest way is share out the root folder.

Then if your shortcut says "C:\Documents and Settings\UserName\My Documents\My Music\Artist\Song.mp3"

replaace with "\\Computer A\C$\Documents and Settings\UserName\My Documents\My Music\Artist\Song.mp3"

Yes, it's easy for me to change the script and hard-code the correct UNC path name. I'd like to be able to run this script on ANY computer. For example, my brother has a home network -- same consideration....

The question is: I have a path name. What is the UNC path name? Of course, there only is a valid UNC path name if the folder that the file actually resides in is shared, which is the heart of the question.

Share this post


Link to post
Share on other sites

Isn't there some way to enumerate all the shares on a system? If so, then if the path for that share could be determined,

the question could be answered!

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

c$ share requires you to login as an admin (if you have the same user with the same password it will work aswell) same with admin$ share.

HKLM\SYSTEM\CurrentControlSet\Services\lanmanserver\Shares holds your other shares, with permissions. These values can be read with either reg.exe or RegEnumVal(), depends on your preference.

Edited by jinxter

> there are 10 types of people in the world, those who understand binary and those who don't.

Share this post


Link to post
Share on other sites

c$ share requires you to login as an admin (if you have the same user with the same password it will work aswell) same with admin$ share.

HKLM\SYSTEM\CurrentControlSet\Services\lanmanserver\Shares holds your other shares, with permissions. These values can be read with either reg.exe or RegEnumVal(), depends on your preference.

Thanks a bunch Jinxter -- answers the question EXACTLY.

The lanmanserver\Shares entries contain the full path name for a given share. On the computer I'm running on, given a path name, I can ask the question: is the folder shared or a higher-level folder in the path shared? If so, I create the shortcut using the computer name and the share name, followed by the rest of the path nodes.

Now I can share the folder that contains the shortcuts and the shortcut targets will be valid on any computer in the home network.

Great!

Thanks again, so very much.

Paul

Share this post


Link to post
Share on other sites

Glad to be of service :whistle:


> there are 10 types of people in the world, those who understand binary and those who don't.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0