Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-03-25
8
Medium Priority
?
260 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:qvn7
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 5

Expert Comment

by:xylog
ID: 35221914
This will return the home directory that is set in active directory:

dsquery user -samid usernam|dsget user -hmdir

0
 
LVL 46

Expert Comment

by:aikimark
ID: 35222074
where will this script run?
0
 

Author Comment

by:qvn7
ID: 35222598
@ 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!!!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:qvn7
ID: 35222599
@ aikimark

Where will this script run?  Either my primary workstation or one of the file servers hosting the home directories data.
0
 
LVL 5

Expert Comment

by:xylog
ID: 35222798
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.
0
 
LVL 14

Accepted Solution

by:
yehudaha earned 2000 total points
ID: 35226366
hello

edit line 1 to add your home folder server names

when it's ask for folder name you can input "like" name input, what do i mean:

if you look for " jack" folder but you not sure if there addition to the name like: "jackfolder".
you can put just jack and the script will search for any folder have jack in the name.
ArrComputers = Array("homeserver1,homeserver2")

dir = InputBox("Enter Directory Name")

For Each strComputer In ArrComputers
Set objWMIService = GetObject _
    ("winmgmts:" & "!\\" & strComputer & "\root\cimv2")
Set colFolders = objWMIService.ExecQuery _
   ("Select * From Win32_Directory Where name Like '%\\" & Dir & "%'")
   
For Each objFolder in colFolders
    Wscript.Echo "Found: " & objFolder.Name & " ON " & strComputer
Next
Next

MsgBox "done"

Open in new window

0
 

Author Comment

by:qvn7
ID: 35233004
Thanks for ALL of your help!!!  Have a good day!!!
0
 
LVL 14

Expert Comment

by:yehudaha
ID: 35234373
great, please close the question and choose the answer/s you like
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question