×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

VBS - Create NewFile With Adm Users

VBS - Create NewFile With Adm Users

VBS - Create NewFile With Adm Users

(OP)
Hi all,

I have a script that collects users members of the local administrators group and this script creates a file for each user, I would like to know if it is possible to generate these files and then unify in a single file example:

administrator.txt
user_X.txt
admin.txt

New file:

administrator_user_X_admin.txt

The problem is that the amount of users varies from computer to computer. I'll copy the script that does this collection. I appreciate who can help me.

'===================================
On Error Resume Next

Set Shell = CreateObject("WScript.Shell")
strOS = shell.ExpandEnvironmentStrings("%OS%")

If strOS = "Windows_NT" Then
strVerKey = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\"
strVersion = Shell.regread(strVerKey & "ProductName")
Else
End if

If strVersion = "Windows Server 2008 R2 Enterprise" Or strVersion = "Windows Server 2008 R2 Standard" Or strVersion = "Windows Server 2012 R2 Standard" Or strVersion = "Windows Server 2012 R2 Enterprise" Or strVersion = "Microsoft Windows Server 2003 R2" Then
WScript.Quit
Else

Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName

Dim UsersGroup
Const ForAppending = 8

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators")
For Each objUser in objGroup.Members
UsersGroup = objUser.Name
If UsersGroup = "Administrador" Or UsersGroup = "Domain Admins" Or UsersGroup = "RemoteDesktop_DM" Or UsersGroup = "RemoteDesktop_SD" Then
Else

Set objFolder = objFSO.CreateFolder("C:\Folder")
Set objFolder = objFSO.CreateFolder("C:\Folder\ADMGROUP")
Set objTextFile = objFSO.OpenTextFile("C:\Folder\ADMGROUP\" & strComputer & "_" & UsersGroup & ".txt", ForAppending, TRUE)
objTextFile.Close
objFSO.CopyFolder "C:\Folder\ADMGROUP" , "\\Newtwork\Logs\ADMGROUP", True
End If
Next

End If

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close