yehudaha
asked on
EnumNetworkDrives Method in batch script
hey,
is there any way to check above in a batch file ?
my idea was to play with net use, but how can i capture specific drive UNC ?
one last thing after i got the unc how can i play with the parts ?
what i mean for example :
\\serverA\public
how to "pull" serverA and lets say ping it ?
or check if the folder name it's public and if not remap another folder ?
if i asking to much in one question just say :-)
thanks
is there any way to check above in a batch file ?
my idea was to play with net use, but how can i capture specific drive UNC ?
one last thing after i got the unc how can i play with the parts ?
what i mean for example :
\\serverA\public
how to "pull" serverA and lets say ping it ?
or check if the folder name it's public and if not remap another folder ?
if i asking to much in one question just say :-)
thanks
ASKER
thanks Qlemo for your respone
the output i'm getting is the drive letter and the host name.
my direction in this script is to pull the host name, ping it, pull the subnet of the host in the share
and check if it's match the local subnet if not remove the non matching share.
we have branches with local file servers, but the problem that the users is traveling between the branches
and getting the wrong drive mapping from there original branches, using it and causing big slow down.
the output i'm getting is the drive letter and the host name.
my direction in this script is to pull the host name, ping it, pull the subnet of the host in the share
and check if it's match the local subnet if not remove the non matching share.
we have branches with local file servers, but the problem that the users is traveling between the branches
and getting the wrong drive mapping from there original branches, using it and causing big slow down.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
mm nice one
batch scripting very intresting,
do you have a suggestion how can i learn batch ?
even better how did you learn ? :-)
batch scripting very intresting,
do you have a suggestion how can i learn batch ?
even better how did you learn ? :-)
I'm a dinosaur, we had nothing else in the early days before the World War ;-)
Seriously, I don't know of a good tutorial. It might exist, however.
A good start is to read the help comming from
if /?
set /?
for /?
cmd /?
help
All stuff used in above script can be derived out of those help pages.
Seriously, I don't know of a good tutorial. It might exist, however.
A good start is to read the help comming from
if /?
set /?
for /?
cmd /?
help
All stuff used in above script can be derived out of those help pages.
ASKER
Thanks For The Help !
ASKER
>> I'm a dinosaur, we had nothing else in the early days before the World War
:-)
:-)
for %U in (\\serverA\public) do @echo %~nU
will echo the share name only (in a batch file, you need to use %%U and %%~nU).
To process the net use output, for /F is useful:
for /F "tokens=2-3 delims=\ " %S in ('net use ^| find "\"') do @echo Server: %S Share: %T
Now, the last does not make sense. It is not necessary to check if a share already is used on a specific server, but others do. If you need the share, just map it with net use. If it exists already, the command will silently do nothing.