Jump to content

Recommended Posts

Posted (edited)

Ok so I want to create a batch file that will automate a device clean feature, I want it to remove and delete all profiles except for a few folders such as "All Users and tivpriv" anyway this is what i have so far but it doesn't work quite well can anyone help me out? This is meant to allow you to specify the device id and then delete everything form the Documents and Settings folder other than all users and tivpriv for now, it works for the device im on but it wont work for another device on the same network?? Im running it as an administrator. If i change the code under the CONTINUE label to a ping command it works fine but the actual code thats meant to do deletion part wont work on any other networked device other than the one im on???

@echo off

set /p DEVICE=Device?

:START

IF NOT EXIST "\\%DEVICE%\C$\Documents and Settings\" (GOTO DEVICE)

IF EXIST "\\%DEVICE%\C$\Documents and Settings\" (GOTO CONTINUE)

:CONTINUE

FOR /D %%? IN ("\\%DEVICE%\c$\Documents and Settings\*") DO (

ECHO/%%~N? |FINDSTR/IL "ALL\ USERS tivpriv" >NUL 2>&1||RD/S/Q "%%~?")

:DEVICE

ECHO.

echo ############################# Device Error! ###############################

echo # #

ECHO # Device not found! It's either offline or it does not exist, please #

ECHO # re-enter the correct details and make sure the device is online. #

echo # #

echo ###########################################################################

ECHO.

set /p DEVICE=Device?

GOTO START

pause

DeviceClean.txt

Edited by serb87

Posted

Deleting directories in Documents and Settings is not the same as removing non required profiles.

Microsoft from Win2K provided a command line tool specifically for doing that, Delprof.exe.

If you're using later operating systems then try Delprof2

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...