|
View Full Version : Move profiles to another folder
Mark Coutinho 10-03-2005, 07:41 AM 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?
Royce 10-03-2005, 09:33 PM 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
"Mark Coutinho" wrote:
> 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?
>
Mark Coutinho 10-04-2005, 10:11 AM 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!
On Mon, 3 Oct 2005 13:33:13 -0700, "Royce"
<Royce@discussions.microsoft.com> wrote:
>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
>
>
>
>"Mark Coutinho" wrote:
>
>> 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?
>>
David Trimboli 10-04-2005, 03:21 PM >>"Mark Coutinho" wrote:
>>
>>>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?
> On Mon, 3 Oct 2005 13:33:13 -0700, "Royce"
> <Royce@discussions.microsoft.com> wrote:
>
>>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
Mark Coutinho wrote:
> 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
Royce 10-04-2005, 06:51 PM 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
"Mark Coutinho" wrote:
> 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!
>
> On Mon, 3 Oct 2005 13:33:13 -0700, "Royce"
> <Royce@discussions.microsoft.com> wrote:
>
> >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
> >
> >
> >
> >"Mark Coutinho" wrote:
> >
> >> 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?
> >>
>
>
Mark Coutinho 10-06-2005, 08:02 AM 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!
On Tue, 4 Oct 2005 10:51:10 -0700, "Royce"
<Royce@discussions.microsoft.com> wrote:
> @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 10-06-2005, 10:37 PM Your welcome...
"Mark Coutinho" wrote:
> 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!
>
> On Tue, 4 Oct 2005 10:51:10 -0700, "Royce"
> <Royce@discussions.microsoft.com> wrote:
>
> > @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 10-06-2005, 11:52 PM 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
"Mark Coutinho" wrote:
> 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!
>
> On Tue, 4 Oct 2005 10:51:10 -0700, "Royce"
> <Royce@discussions.microsoft.com> wrote:
>
> > @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
>
>
|
|
|