Move profiles to another folder

  • Thread starter Thread starter Mark Coutinho
  • Start date Start date
M

Mark Coutinho

Hello,

Because we're switching domains here, we have to get rid of all the
old user profiles. But not at once - first they have to be put in a
temporary directory. A few months after installation they can be
thrown away.

So here's my question.
How do I make a batch that moves all user profiles EXCEPT the system
ones (Default User, Administrator, Local Administrator) to the folder
D:\WINNT\TEMP?
 
Try this:

@echo off
title Please Wait...
cd "c:\docume~1"
for /f "tokens=*" %%i in ('dir /b') do set profile="%%i"&call :sub
goto next
:sub
for /l %%i in (1,1,12) do echo.
echo Please wait while files are being copied for %profile% profile.
if /i %profile% == "administrator" goto next
if /i %profile% == "all users" goto next
if /i %profile% == "default user" goto next
if /i %profile% == "networkservice" goto next
if /i %profile% == "localservice" goto next
xcopy %profile% "d:\winnt\temp\%profile%" /e /q /h /k /o /y /i
:next
cls
 
Great Roy,

works like a clock

only thing is that the directories have to be MOVED from d:\docu &
settings.
XCOPY just copies it.

So what would the line be to achieve this?

Thanks again!
 
Mark said:
Great Roy,

works like a clock

only thing is that the directories have to be MOVED from d:\docu &
settings.
XCOPY just copies it.

So what would the line be to achieve this?


First, change the third line to:

cd /d "%allusersprofile%\.."

Now it doesn't matter where the profiles are stored; the script will
automatically move the current drive and directory to that folder.

Now change the third-to-last line to this (all one line; ignore the
line-wrap):

xcopy %profile% "d:\winnt\temp\%profile%" /e /q /h /k /o /y /i && rd /s
/q %profile%


David
Stardate 5759.3
 
the only line that was changed was the 3rd to last. this just ensures that
the profile was copied to the d:\ drive before it deletes it from the c:\
drive.

try this:

@echo off
title Please Wait...
cd "c:\docume~1"
for /f "tokens=*" %%i in ('dir /b') do set profile="%%i"&call :sub
goto next
:sub
for /l %%i in (1,1,12) do echo.
echo Please wait while files are being copied for %profile% profile.
if /i %profile% == "administrator" goto next
if /i %profile% == "all users" goto next
if /i %profile% == "default user" goto next
if /i %profile% == "networkservice" goto next
if /i %profile% == "localservice" goto next
xcopy %profile% "d:\winnt\temp\%profile%" /e /q /h /k /o /y /i
if exist "d:\winnt\temp\%profile%" rmdir /s /q "c:\docume~1\%profile%"
:next
cls
 
Royce: this does exactly what I want!
Thank you very much for your help; this will save me quite some hours
this weekend when we're switching servers here!
 
Your welcome...

Mark Coutinho said:
Royce: this does exactly what I want!
Thank you very much for your help; this will save me quite some hours
this weekend when we're switching servers here!
 
sorry mark, but if you havent used the batch yet, use this one instead. it
will run way faster! i should have caught the "moved" part when i first read
your post. my fault...

@echo off
title Please Wait While Profiles Are Being Moved...
cd "c:\docume~1"
for /f "tokens=*" %%i in ('dir /b') do set profile=%%i&call :sub
goto next
:sub
for /l %%i in (1,1,12) do echo.
if /i "c:\docume~1\%profile%" == "c:\docume~1\administrator" goto next
if /i "c:\docume~1\%profile%" == "c:\docume~1\all users" goto next
if /i "c:\docume~1\%profile%" == "c:\docume~1\default user" goto next
if /i "c:\docume~1\%profile%" == "c:\docume~1\networkservice" goto next
if /i "c:\docume~1\%profile%" == "c:\docume~1\localservice" goto next
move /y "c:\docume~1\%profile%" "d:\winnt\temp"
:next
cls
 
Back
Top