Get all user accounts

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Get all user accounts

Post by alemrantareq » Tue Feb 23, 2010 8:47 pm

Hi, can anyone tell me is there any way to get all the user accounts list in a field which are shown in the welcome screen? Replies most appreciated.......... :lol:

shadowslash
Posts: 344
Joined: Tue Feb 24, 2009 6:14 pm
Contact:

Re: Get all user accounts

Post by shadowslash » Wed Feb 24, 2010 3:42 am

alemrantareq wrote:Hi, can anyone tell me is there any way to get all the user accounts list in a field which are shown in the welcome screen? Replies most appreciated.......... :lol:
Can you be specific? If I got it right, you want to get the list of accounts in a computer and list it in a field control. Is that your point? If it is, I cooked up a code below for you. Put it inside a button or anywhere that will be clicked to see how it works.

Code: Select all

on mouseUp
   local tDirectory,tDocsPath,tUsers
   
   //Backup the current directory first
   put the directory into tDirectory
   
   // Put the user profile's path into tDocsPath
   put $USERPROFILE into tDocsPath
   
   // Remove the trailing username
   set the itemDel to backslash
   delete last item of tDocsPath
   
   // Set the current directory to the result and check the folders
   set the directory to tDocsPath
   put the folders into tUsers
   
   // Filter out the double "." on top of tUsers
   filter tUsers without ".."
   
   // Return the previous current directory
   set the directory to tDirectory
   
   // Show dialog box.
   answer tUsers titled ((the num of lines in tUsers) && "users found!!")
end mouseUp
Hope this helps...
- Shedo Chung-Hee Surashu
Parañaque, Philippines
Image
Image

shadowslash
Posts: 344
Joined: Tue Feb 24, 2009 6:14 pm
Contact:

Re: Get all user accounts

Post by shadowslash » Wed Feb 24, 2010 3:52 am

P.S., I also uploaded the sample script into revOnline. You can get it at: http://revonline2.runrev.com/stack/450/ ... nvironment
Parañaque, Philippines
Image
Image

alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Re: Get all user accounts

Post by alemrantareq » Wed Feb 24, 2010 4:38 am

A Lot of Thanks shadowslash.......It works Great ! But it brings some unnecessary user accounts (i.e. Default User, NetworkService, LocalService). Any idea to avoid them?

shadowslash
Posts: 344
Joined: Tue Feb 24, 2009 6:14 pm
Contact:

Re: Get all user accounts

Post by shadowslash » Wed Feb 24, 2010 4:44 am

alemrantareq wrote:A Lot of Thanks shadowslash.......It works Great ! But it brings some unnecessary user accounts (i.e. Default User, NetworkService, LocalService). Any idea to avoid them?
Here's a modified version of my script above in case you don't want Default User, NetworkService and LocalService to show.

Code: Select all

on mouseUp
   local tDirectory,tDocsPath,tUsers,tUnwantedAccounts
   
   //Backup the current directory first
   put the directory into tDirectory
   
   // Put the user profile's path into tDocsPath
   put $USERPROFILE into tDocsPath
   
   // Remove the trailing username
   set the itemDel to backslash
   delete last item of tDocsPath
   set the itemDel to comma
   
   // Set the current directory to the result and check the folders
   set the directory to tDocsPath
   put the folders into tUsers
   
   // Filter out the double "." on top of tUsers
   filter tUsers without ".."
   
   // Define the unwanted accounts
   put "Default User,NetworkService,LocalService" into tUnwantedAccounts
   
   // Filter out the unwanted accounts of tUsers
   repeat for each item tAcctName in tUnwantedAccounts
      filter tUsers without tAcctName
   end repeat
   
   // Return the previous current directory
   set the directory to tDirectory
   
   // Show dialog box.
   answer tUsers titled ((the num of lines in tUsers) && "users found!!")
end mouseUp
Now you can customize the usernames that shouldn't be shown to the user by putting it into tUnwatedAccounts as comma-delimited values.

- Shedo Chung-Hee Surashu
Parañaque, Philippines
Image
Image

alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Re: Get all user accounts

Post by alemrantareq » Wed Feb 24, 2010 8:33 am

Thanks for the Great Workout !!! Cheers shadowslash.....

shadowslash
Posts: 344
Joined: Tue Feb 24, 2009 6:14 pm
Contact:

Re: Get all user accounts

Post by shadowslash » Wed Feb 24, 2010 8:35 am

alemrantareq wrote:Thanks for the Great Workout !!! Cheers shadowslash.....
Cheers!! Image
Parañaque, Philippines
Image
Image

Post Reply