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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another Logon script question... sorry!

Status
Not open for further replies.

acford

MIS
Nov 12, 2003
90
0
0
GB
Hi,

I need to map users home folders via vbscript. The path is the following:

\\server1\home$\%username%

I can map to home$ but not get the username part working... please help me...

Thanks
Andy
 
A starting point:
Code:
Set WshShell = CreateObject("WScript.Shell")
WScript.Echo WshShell.ExpandEnvironmentStrings("\\server1\home$\%username%")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Yep, seen that before, very useful.

I managed to work my way through it in the end:

Dim objNetwork
Dim strDriveLetter, strRemotePath, strUserName

strDriveLetter = "H:"
strRemotePath = "\\servername\home$"

Set objNetwork = WScript.CreateObject("WScript.Network")
strUserName = objNetwork.UserName
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath & "\" & strUserName
 
Hi, I have a new problem now...

The script above works a treat unless the home folder does not exist (new user)... I guess I need it to create a folder as the username if it is not there...

Any ideas?
 
You will want to use the FileSystemObject to check if the folder exists and if not create the folder. Following that you will want to call XCACLS to set the folder permissions.

Rather than doing that at login, I would use a script to enumerate AD for users and check for the folders and create where needed. Additionally, what I do is reverse that process and look for user directories that don't have a matching user. I then delete those folders since they are most likely from deleted user accounts.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top