Link to home
Start Free TrialLog in
Avatar of qvn7
qvn7Flag for United States of America

asked on

Is there a VB script to locate one or more home directories for a user?

Is there a way, either VB script or batch file, to locate one or more home directories for a user?  

For example, my LAN ID, qnguye01, is found on two Windows file cluster nodes.  I want to be able to run a VB script or batch file to locate other end users' home directories, if they have one or more floating around somewhere.

TY,
Quan
Avatar of xylog
xylog

This will return the home directory that is set in active directory:

dsquery user -samid usernam|dsget user -hmdir

Avatar of aikimark
where will this script run?
Avatar of qvn7

ASKER

@ xylog:

Thanks, but what I need is to locate other home directories that isn't the main one under the "Profile" tab in Active Directory.  

My main home directory folder is located here:

\\HomeServer1\SharedDrive1\SharedVol1\qnguye01

I recently found out that I had another one located somewhere else, like:

\\HomeServer3\SharedDrive4\SharedVol3\qnguye01

Is there a way to locate multiple home directories either using VB script, batch file or dsquery commands?

Thanks!!!
Avatar of qvn7

ASKER

@ aikimark

Where will this script run?  Either my primary workstation or one of the file servers hosting the home directories data.
If you want to locate a directory with a specific name in a specified location you can use a series of "if exist" statements in a batch file:

findhomes.bat
==========
@echo off
if exist \\HomeServer1\SharedDrive1\SharedVol1\%1 echo \\HomeServer1\SharedDrive1\SharedVol1\%1

if exist \\HomeServer3\SharedDrive4\SharedVol3\%1 echo \\HomeServer3\SharedDrive4\SharedVol3\%1

===========

to run:

findhomes qnguye01

Alternatively if you want to search the entire hard drive you can enumerate all the directories with a dir statement:

dir /ad /s |findstr qnguye01

This is a bit slow if you have many directories (say, more than several hundred)

There is a middle ground if you have many volumes you can loop thru them like so:

for /d %%i in (\\HomeServer1\SharedDrive1\*) do if exist  %%i\%1 echo %%i\%1

If you have multiple shares we can loop thru them with the net view command. For multiple servers best bet is to loop thru a list in a text file.
ASKER CERTIFIED SOLUTION
Avatar of yehudaha
yehudaha
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of qvn7

ASKER

Thanks for ALL of your help!!!  Have a good day!!!
great, please close the question and choose the answer/s you like