|
Answer» I have a batch file that I use to delete user profiles from remote PCs. It WORKS great But now I want to modify it so that it can use a text file called PcsLisl.txt that would contain a list of computers. Sample of file below
\\PODA02 \\PODA03 \\PODA04 \\PODA1 \\PODA5 \\PODB02 \\PODB03 \\PODB04 \\PODB05 \\PODB1 \\PODBSW \\PODC03
This is the current batch file below:
REM echo off
net use x: "\\podA1\c$"
x:
RD "\Documents and Settings\gbertin\" /S
cd\
net use x: /delete
I know that this can be done with the FOR command but I have never used that command before and need help with the syntax. I know there are better ways live using Group Policy but I would really prefer to do it using a batch file remotely thus I can choose which workstations to delete the file from with having to use Active DIRECTORY eThis should work. But please try it first WITHOUT deleting anything.
echo off setlocal set log=your logfile set pclist=PcsLisl.txt
FOR /f "skip=2 delims=\ " %%v in ('find "POD" %pclist%') do (
net use x: \\%%v\c$ call :Sub %%v )
endlocal goto :EOF
:Sub %%v
IF %errorlevel% EQU 0 (echo drive c:\ mapped >>%log% ) else ( echo couldn't map drive %errorlevel% >>%log% & GOTO fertig ) rd "x:\Documents and Settings\gbertin\" /S
:: I don't know the errorlevel from the rd command; sorry :: check it also : fertig
net use x: /delete
:EOF
I think you don't need to map the drive. rd "\\%%v\c$\Documents and Settings\gbertin\" /S
Should also work.
hope it helps
uliThere is a special command in the Ressource kit for deleting profiles. "delprof" With this command you don't need to map the drive. Just put it in a for loop.
I fear that only deleting the directory doesn't really delete the profile.
uli
|