Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

List all users on a computer and output to local directory

Posted on 2013-01-26
3
372 Views
Last Modified: 2013-01-27
I am trying to create a script that will list all users on a computer and then save that file as the computer name to a specified directory.  Not knowing much about vbscript, I have googled and come up with the script below that will somewhat work.  The issue  with this script is that it displays a box on the screen for each user account.  

I would like to modify this script so that is will save the output to C:\kworking and name the file the same as the computer name.  I've tried but with my little scripting experience I'm getting nowhere fast.  I'm sure an expert can modify this in a few seconds.

Thanks for any input!




On Error Resume Next

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."
 
Set objRegistry=GetObject("winmgmts:\\" & _
    strComputer & "\root\default:StdRegProv")
 
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys
 
For Each objSubkey In arrSubkeys
    strValueName = "ProfileImagePath"
    strSubPath = strKeyPath & "\" & objSubkey
    objRegistry.GetExpandedStringValue HKEY_LOCAL_MACHINE,strSubPath,strValueName,strValue
    Wscript.Echo strValue
Next
0
Comment
Question by:jplagens
3 Comments
 
LVL 7

Accepted Solution

by:
Scobber earned 500 total points
ID: 38823490
the Windows Scripting Host is 2 parts, Cscript, and wscript

Execute your script with "CScript.exe myscript.vbs" and it will run in console mode

To change the default interpreter, type "cscript //h:cscript //s" from a administrative command prompt

you can then output this to a folder by executing
cscript myscript.vbs >  C:\kworking\%computername%.txt
0
 
LVL 4

Author Comment

by:jplagens
ID: 38823514
It worked perfectly.  Thank you for your assistance.  That does exactly what I need it to do!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question