Clean the net user output command

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
pubk
Posts: 2
Joined: 01 Oct 2023 09:46

Clean the net user output command

#1 Post by pubk » 01 Oct 2023 09:59

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.

Batcher
Posts: 74
Joined: 16 Apr 2009 10:36

Re: Clean the net user output command

#2 Post by Batcher » 02 Oct 2023 18:19

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

pubk
Posts: 2
Joined: 01 Oct 2023 09:46

Re: Clean the net user output command

#3 Post by pubk » 16 Oct 2023 18:15

Thanks
Works like a charm
Sorry for late replay, site had some problems for me.

Post Reply