Gaz Posted November 28, 2012 Posted November 28, 2012 I hate writing scripts or batch files because I always break things. Can anybody help me make a script that makes a folder inside users home directories. For example. The students home folder is C:\students\username on the server. What I need to make is a folder inside the \username folder so, C:\students\username\newfolder I have over 500 accounts to do so I was hoping that I could use some sort of %username% type command or wildcard. I've Googled but im all out of Google Fu today.
Firefox Posted November 28, 2012 Posted November 28, 2012 You could use Group Policy Preference mode, User Configuration to create a folder. Do the users get their home directory mapped as a particular drive? Say it Maps to H:\ you could set the GPP to create H:\new folder
Gaz Posted November 28, 2012 Author Posted November 28, 2012 Arh yes I could but I've not got GPP on my 2003 R2 server.
DT2 Posted November 28, 2012 Posted November 28, 2012 (edited) I hate writing scripts or batch files because I always break things. Can anybody help me make a script that makes a folder inside users home directories. For example. The students home folder is C:\students\username on the server. What I need to make is a folder inside the \username folder so, C:\students\username\newfolder I have over 500 accounts to do so I was hoping that I could use some sort of %username% type command or wildcard. I've Googled but im all out of Google Fu today. CLS ::variables set name=c:\Students\ ::commands md %name%\%username%\nameoffolder add pause if you want it to halt before exiting, else exit. create a .bat and set to run at logon. Should work. Also, if you find the %username% doesn't work (as it pulls the user of the current process and isnt always correct), then use this: for /f "TOKENS=1,2,*" %%a in ('tasklist /FI "IMAGENAME eq explorer.exe" /FO LIST /V') do if /i "%%a %%b"=="User Name:" set _currdomain_user=%%c for /f "TOKENS=1,2 DELIMS=\" %%a in ("%_currdomain_user%") do set _currdomain=%%a & set _curruser=%%b Edited November 28, 2012 by DT2
Firefox Posted November 28, 2012 Posted November 28, 2012 You shouldn't need a 2008 server. GPP's apply to all devices with XP SP3 and above I believe. You should be able to run a Win 7 pc with the RSAT tools installed and this should let you managed these settings :-)
Gaz Posted November 28, 2012 Author Posted November 28, 2012 for /f "TOKENS=1,2,*" %%a in ('tasklist /FI "IMAGENAME eq explorer.exe" /FO LIST /V') do if /i "%%a %%b"=="User Name:" set _currdomain_user=%%c for /f "TOKENS=1,2 DELIMS=\" %%a in ("%_currdomain_user%") do set _currdomain=%%a & set _curruser=%%b Just the kinda stuff I was hoping to avoid. The .bat file sounds promising. If its to run at logon though I'd would need the network map so set name=h:\domaincontroller\students\%username%\newfolder md %name%\%username%\nameoffolder Sould that work?
plexer Posted November 28, 2012 Posted November 28, 2012 If not exist h:\newfolder mkdir h:\newfolder in a logon script assuming you map h: to their home folder. Ben
DT2 Posted November 28, 2012 Posted November 28, 2012 Yeah, you can just stick net use in there in stead of the %name% variable. net use H: \\server\share\%username% md H:\newfolder If H: is already mapped then it's even easier, just omit the net use command.
Gaz Posted November 28, 2012 Author Posted November 28, 2012 Arh I see. Yes H:\ is their home folder. Oh how much easier this would have been if I could have just typed "mkdir c:\students\*\newfolder" where * is the random folder/username. It works on files, why not folders too.
DT2 Posted November 28, 2012 Posted November 28, 2012 Tell me about it..... But, I suppose if it was easy it'd be boring and we'd be paid peanuts..... Oh, wait.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now