Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

There is file that exists in each user profile directory and I need to remove the line from the file in each user profile directory. I'm using a batch script to go through each user profile directory, type the file, use findstr to not display the line, and then re-direct the output to itself. For whatever reason this is not removing the line.

SET ProfileBase=%SystemDrive%\Documents and Settings

for /f "tokens=*" %%a in ('dir /b /ad-h "%ProfileBase%"') do type "%ProfileBase%\%%a\myfile" | findstr /v display >> :%ProfileBase%\%%a\myfile"
share|improve this question
typo: "Docuemnts" -- not in your actual code, maybe? – Lars Rohrbach Jun 22 '12 at 17:15
Ah yes, that was a typo here. I verified that it is correct in my actual code. – hsatterwhite Jun 22 '12 at 17:22

Is using win32 versions of sed and find out of the question? Those could easily do it*. Also, PowerShell might be worth a look.

*) find /path/to/files -type f -iname 'filename' -execdir sed -i -e '/^exact line you want to disappear$/d' {} \;

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.