Link to home
Start Free TrialLog in
Avatar of Net-Eng99
Net-Eng99

asked on

Create the same folder in everyone's home folder

Hi,

I would like a script that will create the same folder in every user's home area. So I would like to create "Folder1" in \\server1\user1\Documents\   \\server1\user2\Documents   \\server1\user9999\Documents ...

But only create this folder if it doesn't already exist.

Is this possible?

Regrads
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Assuming you can get to the server console, this should do it...remove the 'echo' on the last line to make it happen.
If you can't get to the console, map a network drive to the c$ of the remote server:
net use L: \\server1\c$
then adjust the 2nd line of the code to read
cd /d L:\users


@echo off
cd /d c:\users

for /f "delims=" %%a in ('dir /ad /b') do call :process "%%~fa"
goto :eof

:process
set fld=%1

if /i "%fld:~10,-1%" == "All Users" goto :eof
if /i "%fld:~10,-1%" == "Default User" goto :eof
if /i "%fld:~10,-1%" == "Public" goto :eof

echo Creating folder for %fld%
if not exist %fld:~0,-1%\Documents\Folder1" echo md %fld:~0,-1%\Documents\Folder1"

Open in new window

Bah - didn't know oBdA was awake...forgot to refresh, sorry. :^)
Avatar of Bill Prew
Bill Prew

Could be done right at a command line with a simple command like:

for /D %F in ("\\servername\basedir\*.*") do (md "%~F\Documents\Folder1" >NUL 2>NUL)

Open in new window

or in a BAT file as:

for /D %%F in ("\\servername\basedir\*.*") do (md "%%~F\Documents\Folder1" >NUL 2>NUL)

Open in new window

~bp
Avatar of Net-Eng99

ASKER

@oBdA thanks for your solution, I tried that one and it worked perfectly!

Regards
Spot on solution - excellent!