Computing.Net > Forums > Programming > Batch Script

Batch Script

Reply to Message Icon

Original Message
Name: zeiad
Date: March 14, 2007 at 19:21:42 Pacific
Subject: Batch Script
OS: Windows XP
CPU/Ram: 2.8/512
Model/Manufacturer: IBM
Comment:

Hi

I need to make a batch file that deletes all profiles on the local drive of the machines in network.

So i need to roll it out via GPO to delete all files and folders in C:\Documents and Settings\ except for the dir "Administrator" and "All Users".


can anyone help please?

I started it by

del C:\Documents and Settings\*.* /q /s

How do i put the excepetion in and *.* seems to only delete the files inside the dir and not the dir itself.
Can someone help please?


Report Offensive Message For Removal

Response Number 1
Name: Mechanix2Go
Date: March 15, 2007 at 05:48:55 Pacific
Subject: Batch Script
Reply: (edit)

Try this:

::== k3.bat
@echo off
setLocal EnableDelayedExpansion

pushd "C:\Documents and Settings"
for /f "tokens=* delims= " %%a in ('dir /b/ad') do (
if "%%a" neq "Administrator" , if "%%a" neq "All Users" echo rd /s /q "%%a"
)
popd
::==



=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Batch Script

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software