Solved

List all users on a computer and output to local directory

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now