How to create a folder called “Games” on all the users H: (Home drive)

Hi

We have 300 users and I want to create a folder called “Games” on all the students H: drive , which is their Home drive. In the past I have created a folder called "Games"  on some of the students Home drive manually and now I am not sure how many students’ I had manually created the this folder and I can find this only by opening the individual student home folder.
I saw few of the student’s Games folder and there is some data saved on it.

I have two group of students, Year13 and Year14

The UNC path from my windows 7 PC for Year13 students is  \\File server-a\StudentDocs\Year13\Student Name
The UNC path from my windows 7 PC  for Year14 students is \\File server-a\StudentDocs\Year14\Student Name

Please post me  some tutorials  and the exact syntax that i need to run on the command prompt , so that “Games”  folder can be created on all of the student home drives.
Also I don’t want the Games folder that I created in the past not to be replaced  when the command is run as it contains games data.  

Any help much appreciated

Thanks
lianne143Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mohammed KhawajaManager - Infrastructure:  Information TechnologyCommented:
Create a GPO which is a user policy and runs at logon.  The policy will run a batch file which looks something like below:

if exist %homedrive%\games goto end
md %homedrive%\games
:end
0
KimputerCommented:
VBScript:

mainfolder = " \\File server-a\StudentDocs\Year13"

creategamefolders mainfolder

'optionally create more by repeating lines and uncomment
'
'mainfolder = "\\File server-a\StudentDocs\Year14"
'creategamefolders mainfolder


sub creategamefolders (mainfolder)
	
	Set fso=wscript.CreateObject("Scripting.FileSystemObject")
	
	Set r = fso.GetFolder(mainfolder)
	For each f in r.SubFolders
	
		If Not fso.FolderExists(fso.BuildPath(f,"Games")) Then fso.CreateFolder(fso.BuildPath(f,"Games"))
		
	next

	set fso = Nothing
	
	
end sub

Open in new window


Needs to run PER main folder (where all the students are listed)
0
Bill PrewIT / Software Engineering ConsultantCommented:
Here is a BAT script approach you can run from your computer:

@echo off
setlocal

REM Define folders to work with
set BaseDir=\\File server-a\StudentDocs
set YearFolders=Year13,Year14
set NewFolder=Games

REM Process each base year folder
for %%A in (%YearFolders%) do (
  REM Process each student subfolder
  for /d %%B in ("%BaseDir%\%%~A\*") do (
    REM If the new folder to add does not exist, add it
    if not exist "%%~B\%NewFolder%\" (
      md "%%~B\%NewFolder%"
    )
  )
)

Open in new window

~bp
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Mohammed KhawajaManager - Infrastructure:  Information TechnologyCommented:
The GPO is a better option because if a new student is added, the folder will be added automatically.
0
deanomacCommented:
Using a GPO to run a batch file at logon is effective but old fashioned,  The more up to date approach is to use Group Policy Preferences. No batch file required.

See this link for more information on what to do:

http://technet.microsoft.com/en-gb/library/cc730913.aspx

Dean
0
lianne143Author Commented:
Hi

In my case there is a "GAMES" folder in some of the users home drive and don't want them to be replaced. Please let me know what settings I need to put for the GPO I create.

Thanks
0
deanomacCommented:
Use the GPP as I mentioned in my comment, utilising the "Update" Action, which should leave existing Games folders there and only provide the folders with the new settings you define.

Always best practice to test that GPP (or any Group Policy Changes for that matter) on one or a couple of machines with an existing Games folder to be sure though.
0
lianne143Author Commented:
Hi Kimputer

I tried running this .VBS from the server and not sure where I am making the mistake.I am getting an Windows Script Host error. Please help
 
Script: H:\Create Game Folder.vbs
Line:16
Char:2
Error:Path nor found
Code:800A004C
Source: microsoft VBScript runtime error




mainfolder = " \\Fileserver-a\StudentDocs\08"

creategamefolders mainfolder

'optionally create more by repeating lines and uncomment
'
'mainfolder = "\\Fileserver-a\StudentDocs\08"
'creategamefolders mainfolder


sub creategamefolders (mainfolder)
      
      Set fso=wscript.CreateObject("Scripting.FileSystemObject")
      
      Set r = fso.GetFolder(mainfolder)
      For each f in r.SubFolders
      
            If Not fso.FolderExists(fso.BuildPath(f,"Games")) Then fso.CreateFolder(fso.BuildPath(f,"Games"))
            
      next

      set fso = Nothing
      
      
end sub
0
Bill PrewIT / Software Engineering ConsultantCommented:
It looks like you have a leading space in your folder path, try removing that (assuming that folder does actually exist of course).

mainfolder = " \\Fileserver-a\StudentDocs\08"

Open in new window

~bp
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
deanomacCommented:
If you are using Group Policy to push out the VB script, why on earth aren't you using that same Group Policy to push a GPP instead that will do the same job anyway?  Maybe i'm missing something here...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.