![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | How to save output of echo to a file or omit using echo and save it Hi, I have found a lot of scripts that display messages on the screen, but I failed to find one that would save it instead (effectively we should get rid of echo command completely, I assume). I don't want to use "cScript" command to invoke my script as it's not practical in many cases. Can anyone help. Example: ------------------- On Error Resume Next Set objGroup = GetObject _ ("LDAP://cn=Administrators,CN=BuiltIn,...,dc=uk") objGroup.GetInfo arrMemberOf = objGroup.GetEx("member") WScript.Echo "Members:" For Each strMember in arrMemberOf WScript.echo strMember Next --------------------- Thanks a lot. Kamil |
My System Specs![]() |
| | #2 (permalink) |
| | Re: How to save output of echo to a file or omit using echo and save it Kamil wrote: Quote: > > I have found a lot of scripts that display messages on the screen, but > I failed to find one that would save it instead (effectively we should > get rid of echo command completely, I assume). I don't want to use > "cScript" command to invoke my script as it's not practical in many > cases. Can anyone help. Example: > > ------------------- > On Error Resume Next > > Set objGroup = GetObject _ > ("LDAP://cn=Administrators,CN=BuiltIn,...,dc=uk") > objGroup.GetInfo > > arrMemberOf = objGroup.GetEx("member") > > WScript.Echo "Members:" > For Each strMember in arrMemberOf > WScript.echo strMember > Next > --------------------- > redirect the output to a text file. Otherwise you can use the FileSystemObject to write the output to a text file. For example: ========= Option Explicit Dim objGroup, objFSO, strFile, objFile Dim arrMembers, strMember Const ForWriting = 2 Const OpenAsASCII = 0 Const CreateIfNotExist = True ' Specify output file. strFile = "c:\scripts\report.txt" ' Open the file. Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile(strFile, _ ForWriting, CreateIfNotExist, OpenAsASCII) ' Bind to the group object. Set objGroup = GetObject("LDAP://cn=Administrators,cn=BuiltIn,dc=MyDomain,dc=com") ' Retrieve member attribute. ' Trap error if there are no members. On Error Resume Next arrMembers = objGroup.GetEx("member") If (Err.Number = 0) Then On Error GoTo 0 ' Enumerate members and write to file. For Each strMember In arrMembers obFile.WriteLine strMember Next End If On Error GoTo 0 ' Clean up. objFile.Close -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Echo results of script to file | PowerShell | |||
| echo output | PowerShell | |||
| No file open,save, save as | Vista General | |||
| What echo has do with Return value? | PowerShell | |||
| Any Way To Get Rid Of The Echo? | Vista music pictures video | |||