Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Anyone know of a way to change users home folder?

Status
Not open for further replies.

Raziel014

Technical User
Nov 1, 2005
51
NO
Hi! I'm in the need of a visual basic script that edits the users profile and changes the home folder entry to something else. We're installing a new fileserver and don't want to this manually.

The old server is called "terminal" and the new one is called "ringve-fil".

The currently paths is:

\\terminal\ansatt\%username%
\\terminal\elev\%username%

This need to be changed to:

\\ringve-fil\ansatt\%username%
\\ringve-fil\elev\%username%

Can anyone help me with this?
 
get a ref to your domain

Set objDomain = GetObject("WinNT://domainname")

'set a filter on all "user" class objects

loop through your new collection of user class objects
checking the .Property you are concerned with...change where nec with strTemp = aUser.Property, strTemp = Replace(strTemp, "xxx", "yyy"), aUser.Property = strTemp, aUser.SetInfo...etc, etc
 
Yeah, this doesn't tell me squat! :D
Care to give me the code?
 
Set Container = GetObject("WinNT://" & domainnamehere)
Container.Filter = Array("User")
For Each aUser In Container
Wscript.Echo aUser.FullName
Next
 
Yes, but I'm stupid.
I need to make sure the script is complete and working before I execute it cause changing settings like this could probably break the AD.

And I can't see any function that actually CHANGES the home folder? Where is that?
 
its evidently up my arse :)

does the code i presented do anything??? i think it is a starting point, i.e. it returns a collection of user objects...this is a start.

'is this more to your liken???

Set Container = GetObject("WinNT://" & domainnamehere)
Container.Filter = Array("User")
For Each aUser In Container
Wscript.Echo aUser.HomeDirectory
Next

do you know how to compare strings??
 
I don't know how to do anything, besides reading code and putting stuff together. Meaning, I can read some code and understand a bit of the basics, but I don't know how to actually write code from scratch. Or compare strings.
 
have you copied

Set Container = GetObject("WinNT://" & domainnamehere)
Container.Filter = Array("User")
For Each aUser In Container
Wscript.Echo aUser.HomeDirectory
Next
Set Container = Nothing

into a .vbs file, edited the domainnamehere to be something like "mynetbiosdomainame" and ran the code??

this is where you need to start.
 
Yes I have and it only results in an error in the first line at the first letter. I'm sure you mean there should be a bit more at the top ey?

So this script gatheres the information in the home folder container and the last line in the script lets me change it to whatever I please? Sounds fantastic! :)
 
if your domain is DOMAINX then the first line should be

Set Container = GetObject("WinNT://DOMAINX")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top