Solved

List all users on a computer and output to local directory

Posted on 2013-01-26
3
373 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
[X]
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
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

696 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