Tom's Hardware > Forum > Windows XP > Windows XP General Discussion > How to Tody Up Piped files

How to Tody Up Piped files

Forum Windows XP : Windows XP General Discussion - How to Tody Up Piped files

Tom's Hardware: Over 1.4 million members in 6 different countries available to answer all your high-tech questions. Sign up now! Its free!
Word :    Username :           
 

Archived from groups: microsoft.public.windowsxp.general (More info?)

 

Anyone know how to tidy up piped files ? For example if on the command line
you type:

net user>c:\users.txt

The txt file will have a list of users setup on the PC but the way its
setout is in columns of 3. I want a single column for a lookup table say.
Anyone got any suggestions before I start trying to script something ?

Sponsored Links
Register or log in to remove.

Archived from groups: microsoft.public.windowsxp.general (More info?)

 

Jingle Man wrote:

> Anyone know how to tidy up piped files ? For example if on the command line
> you type:
>
> net user>c:\users.txt
>
> The txt file will have a list of users setup on the PC but the way its
> setout is in columns of 3. I want a single column for a lookup table say.
> Anyone got any suggestions before I start trying to script something ?
Hi,

Using a VBScript (.vbs file) is an option.

Put the script below in a file called LocalUsers.vbs, and run it in a
command prompt (cmd.exe), like this:

cscript.exe //Nologo "c:\some path\LocalUsers.vbs" >c:\users.txt


'--------------------8<----------------------
Set oWshNet = CreateObject("WScript.Network" )
' get current computer name
sComputer = oWshNet.ComputerName

Set oComputer = GetObject("WinNT://" & sComputer & ",computer" )
oComputer.Filter = Array("user" )

For Each oUser In oComputer
WScript.Echo oUser.Name
Next
'--------------------8<----------------------


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/s [...] fault.mspx

Reply to Anonymous

Archived from groups: microsoft.public.windowsxp.general (More info?)

 

"Jingle Man" <Jingle Man@discussions.microsoft.com> wrote in message
news:FEF2E18B-5B62-45F4-B016-9CA82325B43F@microsoft.com...
> Anyone know how to tidy up piped files ? For example if on the command
> line
> you type:
>
> net user>c:\users.txt
>
> The txt file will have a list of users setup on the PC but the way its
> setout is in columns of 3. I want a single column for a lookup table say.
> Anyone got any suggestions before I start trying to script something ?

[1]@echo off &setlocal enabledelayedexpansion
[2]for /f "skip=4 delims=" %%i in ('net users^|find /v "The command
completed" ') do (
[3] set ynu=%%i
[4] echo !ynu:~0,25!
[5] if not "!ynu:~25,25!"=="" echo !ynu:~25,25!
[6] if not "!ynu:~50,25!"=="" echo !ynu:~50,25!
[7] )

Each line begins [number]. Lines will be wrapped in transmission and
need to be rejoined. The [number] at the beginning of each line needs
to be removed.

Note that in line 2, FIND filters out the line "The command completed"
(which will be the last line generated by the "Net users" command.) I
suspect (but do not KNOW) that usernames cannot contain a dot. If the
usernames CANNOT contain dot, then use "." in place of "The command
completed" (since the "The command completed" line is terminated by a
dot....)

Pop a

>>filename

after each ECHO and you've got your list in your preferred form.

For batch methods, try alt.msdos.batch.nt or
microsoft.public.win2000.cmdprompt.admin

HTH

....Bill

Reply to Anonymous
Tom's Hardware > Forum > Windows XP > Windows XP General Discussion > How to Tody Up Piped files
Go to:

There are 945 identified and unidentified users. To see the list of identified users, Click here.

Please mind

You are about to answer a thread that has been inactive for more than 6 months.
If you still wish to proceed, please ensure that your posting is original and does not duplicate or overlap any prior responses to this thread.

Add a reply Cancel
Sponsored links
  • Ask the community now
  • Publish
Ad
They won a badge
Join us in greeting them