Check If Network Share Exists

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
alleypuppy
Posts: 82
Joined: 24 Apr 2011 19:20

Check If Network Share Exists

#1 Post by alleypuppy » 04 Oct 2011 18:37

Hello. I am trying to figure out if a network share exists through CMD. I had a few ideas of how to do this, but all seem to fail. First I tried

Code: Select all

C:\>IF EXIST \\[computername]\[share[$]] ECHO Exists
but this does not work. Then I tried connecting to just the computer (no share name) using NET USE and then changing the directory to the share.

Code: Select all

C:\>NET USE * \\[computername]
C:\>CD [share]
This also did not work since I need to specify a share name within the NET USE command to connect to that computer. The reason I don't want to use

Code: Select all

C:\>NET USE * \\[computername]\[share[$]]
is because it will prompt me for a username and password regardless of what is specified for the share, which is what I want to avoid.


Thanks for any help!

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Check If Network Share Exists

#2 Post by Ed Dyreen » 08 Oct 2011 11:31

'
You may ping a computer and if you have the rights you are allowed to see the share.
If you lack the rights you will be prompted to logon !

Code: Select all

C:\PROFSYS\ADMIN>net view \\192.168.1.14
Gedeelde bronnen op \\192.168.1.14



Sharenaam   Type    Gebruikt als  Opmerking

-------------------------------------------------------------------------------
COMP        Schijf  S:
ED-SERV-0   Schijf  W:
SharedDocs  Schijf
De opdracht is voltooid.

alleypuppy
Posts: 82
Joined: 24 Apr 2011 19:20

Re: Check If Network Share Exists

#3 Post by alleypuppy » 08 Oct 2011 21:15

Ed Dyreen wrote:'
You may ping a computer and if you have the rights you are allowed to see the share.
If you lack the rights you will be prompted to logon !

Code: Select all

C:\PROFSYS\ADMIN>net view \\192.168.1.14
Gedeelde bronnen op \\192.168.1.14



Sharenaam   Type    Gebruikt als  Opmerking

-------------------------------------------------------------------------------
COMP        Schijf  S:
ED-SERV-0   Schijf  W:
SharedDocs  Schijf
De opdracht is voltooid.

Thank you, but I actually solved my problem myself earlier today and I was just about to post on my thread saying that I have resolved my problem. But thanks anyway!

Post Reply