Solved

List all users on a computer and output to local directory

Posted on 2013-01-26
3
371 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

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