1.

Solve : Please Help with Batch File to Delete Profiles?

Answer»

Hello Everyone,

I am trying to write a .bat that I can set to delete profiles in
c:\DOCUMENTS and settings. I want to be able to delete all profiles, except five of them. I am HOWEVER under the impression that you can't select files to not delete, so as a work around I have copied them out to a TEMP folder, then running the DEL /q /s but it's not working. Is there something that I am missing?

Here is my file:

cd c:\

REM Creating the directories to copy the profiles into.

mkdir c:\Temp_Prof
mkdir "c:\Temp_Prof\All Users"
mkdir "c:\Temp_Prof\Default User"
mkdir c:\Temp_Prof\ms-admin
mkdir c:\Temp_Prof\ms-libtech
mkdir c:\Temp_Prof\ms-faculty

REM Xcopying the profiles to the temp folders created above.

cd c:\documents and settings
xcopy "all Users" "c:\Temp_Prof\All Users" /m /e /v /c /h /k /y /x
xcopy "Default User" "c:\Temp_Prof\Default User" /m /e /v /c /h /k /y /x
xcopy ms-admin c:\Temp_Prof\ms-admin /m /e /v /c /h /k /y /x
xcopy ms-libtech c:\Temp_Prof\ms-libtech /m /e /v /c /h /k /y /x
xcopy ms-faculty c:\Temp_Prof\ms-faculty /m /e /v /c /h /k /y /x

REM DELETING profiles in Documents and settings.

del /q /s *.*

REM Recreating profile folders in Documents and Settings.

mkdir "c:\documents and settings\All Users"
mkdir "c:\documents and settings\Default User"
mkdir c:\documents and settings\ms-admin
mkdir c:\documents and settings\ms-libtech
mkdir c:\documents and settings\ms-faculty

REM Copying files from the temporary folders back to the proper profiles.

cd c:\Temp_Prof
xcopy "all Users" "c:\documents and settings\All Users" /m /e /v /c /h /k /y /x
xcopy "Default User" "c:\documents and settings\Default User" /m /e /v /c /h /k /y /x
xcopy ms-admin "c:\documents and settings\ms-admin" /m /e /v /c /h /k /y /x
xcopy ms-libtech "c:\documents and settings\ms-libtech" /m /e /v /c /h /k /y /x
xcopy ms-faculty "c:\documents and settings\ms-faculty" /m /e /v /c /h /k /y /x

REM Deleting c:\Temp_Prof and its contents

rmdir /s /q c:\Temp_Prof



Thank you to anyone that can offer any help.



Discussion

No Comment Found