Solved

Modify the VBScript to create folder and give rights to it

Posted on 2004-10-04
3
513 Views
Last Modified: 2008-02-20
I have a simple vbscript that creates a folder called "home" locally on my PC. I want to modify the script so it can be used to create a home directory for ANY user on a file server, give the user(modify) rights to their home directory. This script will give the directory the users login name. I want the script to be able to run from any pc within my office, as long as the user running the script has the rights to do it.

I have a Windows 2003 AD domain, the PC's and Servers are all Win2kPro, WinXP, Win2k Server and Win2k3 servers...

ParentFolder = "C:\"
set objShell = CreateObject("Shell.Application")
set objFolder = objShell.NameSpace(ParentFolder)
objFolder.NewFolder "home"
0
Comment
Question by:bernardb
3 Comments
 
LVL 3

Accepted Solution

by:
thunder_moose earned 500 total points
ID: 12224921
Hey there,

To create a folder with the users username, use the following:

Set objNet = CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CreateFolder("\\Yournetwork\Drive\" & objNet.UserName)
Set objFSO = Nothing
Set objNet = Nothing

To set the permissions of the folder, check this thread:
http://www.experts-exchange.com/Security/Win_Security/Q_21019361.html

Hope that helps,
TM
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

A short article about a problem I had getting the GPS LocationListener working.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

786 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