Remove specific words from a text file

Viewed 32

I need to be able to store all the Users on a remote PC in the file Users.txt; afterwards, I need to remove some users from that file, or create a new file, NwUsers.txt, with some of the names removed.

The usernames that would be removed from the file are All Users, Default, Public, and WindowsHelp.

I am not quite sure what command would allow me to do that, can someone please help me to complete this script;

TYPE con >> PcList.txt
For /F %%A in (PcList.txt) do dir /ad /b \\%%A\C$\Users > Users.txt
1 Answers

this script below is working for me and it allows me to list the users in the text file "Users .txt" without listing or removing:

  • All Users
  • Default
  • Public
  • WindowsHelp

Using > the new list is piped out or outputted to the same file, thus replacing the old info. One can change the name of the file to output the info to a new file all together.

TYPE con >> PcList.txt
For /F %%A in (PcList.txt) do dir /ad /b \\%%A\C$\Users > Users.txt

TYPE Users00.txt  | findstr /v /i /r "All Users" | findstr /v /i /r "Default" | findstr /v /i /r "Public" | findstr /v /i /r "WindowsHelp" > users00.txt
Related