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!

Logon Script - Create a new home folder

Status
Not open for further replies.

acford

MIS
Nov 12, 2003
90
0
0
GB
So, here is what I am trying to do:

I have a logon script that maps drives and printers and runs various bits and pieces. I recently added some code (below) to map a users home folder depending on their username.

*****
strUserName = WSHNetwork.UserName
WSHNetwork.MapNetworkDrive "H:", "\\servername\home$" & "\" & strUserName
*****

Now, I am having trouble getting code to create a new user folder if one does not exist in the destination path...

Any ideas?
 
Have a look at the FolderExists and CreateFolder methods of the FileSystemObject.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
you can use the following functions:

Input: - Path: the path where the folder is suppose to be
- FolderName: the name of the folder you want to check for
Output: - True: if the folder exists
- False: if the folder does not exist
--------------------------------------------
function CheckIfFolderExists(byVal Path, byVal FolderName)
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Dim FullPath
FullPath = Path & FolderName
if objFSO.FolderExists(FullPath) Then
CheckIfFolderExists = True
Else
CheckIfFolderExists = False
End if
Set objFSO = nothing
End function

Input:
- Path: path where you want to create the folder
- NewFolderName: the name of the new folder Output:
- True: if the folder is created successfully
- False: if the folder creation failed
------------
function CreateNewFolder(byVal Path, byVal NewFolderName)
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Dim FullPath
FullPath = Path & NewFolderName
if Not objFSO.FolderExists(FullPath) Then
objFSO.CreateFolder(FullPath)
CreateNewFolder = True
Else
CreateNewFolder = False
End if
Set objFSO = nothing
End function


cheers
 
And I would suggest you also use XCACLS to set permissions on the folder so other users can't access it.

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