Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

List all users on a computer and output to local directory

Posted on 2013-01-26
3
Medium Priority
?
395 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

916 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