0

Is there any way in a batch script to take a shared network path on my computer and get the absolute path to that directory?

Example: I'm running a batch file on TESTBOX. I know the "stuff" folder on TESTBOX is shared on the network. Can I get the absolute path to "stuff"? If "stuff" were in C:\stuff then I want this:

Command = GETPATH \\TESTBOX\stuff

Result = C:\stuff

3
  • Are you saying you want to know what drive the share is located on the server? Commented Nov 18, 2015 at 2:26
  • No server, just my local machine. I'm sharing a folder with others and I want to know the absolute path of that folder. Commented Nov 20, 2015 at 19:18
  • Not understanding how you wouldn't already know what the path is. Commented Nov 20, 2015 at 19:21

2 Answers 2

2

You can try to ask wmi for the share information

wmic share where "name='stuff'" get path
Sign up to request clarification or add additional context in comments.

1 Comment

Awesome, this worked exactly how I wanted it to! Thanks.
0

Any shared folders you have on your local computer can also be seen using the NET SHARE command.

H:\>net share

Share name   Resource                        Remark

-------------------------------------------------------------------------------
C$           C:\                             Default share
IPC$                                         Remote IPC
ADMIN$       C:\windows                      Remote Admin
STUFF        C:\STUFF
The command completed successfully.

So if the share name is stuff you can extract the output of the NET SHARE command into a variable by encapsulating it in a FOR /F command.

FOR /F "TOKENS=1* delims= " %%G IN ('net share ^|find /I "stuff"') DO SET sharepath=%%H

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.