Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Adding "Wscript.echo" in place of Report.txt in VBS?

$
0
0

Hi, This script gets remote user's membership info and saves a report.txt as a result.

Can this code be changed with wscript.echo in place of Report.txt

I tried to change it but i couldnt :( Thank you in advance

Note: I am afraid Jrv responds or answers to me :(

strUsers = InputBox("Enter Username: ")
arrUsers = Split(strUsers, ",")

If strUsers <> "" Then
On Error Resume Next
Err.Clear

'("WScript.Network")
Set fs = CreateObject ("Scripting.FileSystemObject")
Set outFile = fs.CreateTextFile (".\Report.txt")

outFile.WriteLine "Active User's Membership"
For x = 0 to UBound(arrUsers)
	arrUsers(x) = Trim(arrUsers(x))
	If x = 0 Then
		'outFile.WriteLine "USER: " & arrUsers(x)
	Else
		outFile.WriteLine "        " & arrUsers(x)
	End If
Next 
outFile.WriteLine "==========="
For x = 0 to UBound(arrUsers)
	Call getGroups(arrUsers(x))
Next

Wscript.echo "Check the Report (report.txt) File!"


Sub getGroups(strUser)
	Set oNetwork = CreateObject("WScript.Network")
	strDomain = oNetwork.UserDomain
	On Error Resume Next
	Set oUser = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
	If Err.Number <> 0 Then
		outFile.WriteLine strUser & " not found..."
		Exit Sub
	End If
	Err.Clear
	On Error Goto 0
	outFile.WriteLine strUser & " - " & oUser.FullName

	For Each strGroup In oUser.Groups
		outFile.WriteLine "" & strGroup.Name
	Next
End Sub

ElseIf strUsers = "" Then
	WScript.Echo "Cancelled."
End If


\_(ツ)_/ twitter.com/serdaruzun




Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>