Page 1 of 1

Clean the net user output command

Posted: 01 Oct 2023 09:59
by pubk
Hello
New user here.

I am trying to get a clean output from net user /domain command. I want to get each user in a separate line rather than columns. but I was unable to get users pass the first column.

I did a little research and came upon this.

But the solutions posted here also don't seem to work. besides that they print the extra lines that command produces(which I can remove by using findstr /v but have to create several temp files) they don't print out all the users.

How can I print all the users in a separate lines? I think I must use for/f but I am not that familiar with it. any explanation would be greatly helpful.

Re: Clean the net user output command

Posted: 02 Oct 2023 18:19
by Batcher
test-1.bat

Code: Select all

@echo off
set "Ignore1=The command completed successfully."
for /f "skip=4 tokens=1-3" %%a in ('net user ^| findstr /v /i /c:"%Ignore1%"') do (
    if "%%a" neq "" (
        echo,%%a
        if "%%b" neq "" (
            echo,%%b
            if "%%c" neq "" (
                echo,%%c
            )
        )
    )
)
pause

Re: Clean the net user output command

Posted: 16 Oct 2023 18:15
by pubk
Thanks
Works like a charm
Sorry for late replay, site had some problems for me.