Outputting in comma delimited format

cross6

Senior member
Jun 16, 2005
508
0
0
I'm using this script:

ComputerName = InputBox("Enter the name of the computer you wish to query")

winmgmt1 = "winmgmts:{impersonationLevel=impersonate}!//"& ComputerName &""

Set UserSet = GetObject( winmgmt1 ).InstancesOf ("Win32_UserAccount")

for each User in UserSet

WScript.Echo "==============================================="
WScript.Echo "Information for " & User.Name
WScript.Echo "The full username for the specified computer is: " & User.Fullname
WScript.Echo "Account Locked? " & User.Lockout
WScript.Echo "Password can be changed?: " & User.PasswordChangeable
WScript.Echo "Password is expirable: " & User.PasswordExpires
WScript.Echo "==============================================="
Next


I run it with "cscript c:\myscript.vbs > data.txt"

to output it to a text file

but how can I format the output for comma delimited?

I tried with wscript and it wouldn't accept all the commas

I need it to be:

user.name, user.fullname, user.lockout, etc

 

Zontor

Senior member
Sep 19, 2000
530
0
0
I don't do much windows scripting but it would seem to me that you could do:

WScript.Echo "Information for" & User.Name & ", "
WScript.Echo "The full username for the specified computer is: " & ", "

and so forth.
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
For comma delimited to be imported into excel, etc. you need to just write the fields and "," not include text like "this is the name:"

jones,bob,552378902,42
smith,john.443256789,11

tricky part: for fields containing a quote (") you need to wrap the field in quotes and use _2_ quotes inside:

tick,the,12345678,32,"yells ""spoon!"" in battle"