Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Other Programming > VBScript
VBScript For questions and discussions related to VBScript.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VBScript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 14th, 2005, 04:06 PM
Registered User
Join Date: Jul 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default need help with vbscript (easy for most)

Need help. I want to be able to modify the script below to write the output to a file instead of the screen. Thank you. This is a simple script that lists Disabled Accounts in A.D.



Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
    "<GC://dc=fabrikam,dc=com>;(objectCategory=User)" & _
        ";userAccountControl,distinguishedName;subtree "
Set objRecordSet = objCommand.Execute

intCounter = 0
Do Until objRecordset.EOF
        WScript.echo objRecordset.Fields("distinguishedName") & " is disabled"
        intCounter = intCounter + 1
    End If

WScript.Echo VbCrLf & "A total of " & intCounter & " accounts are disabled."


Reply With Quote
  #2 (permalink)  
Old July 15th, 2005, 05:09 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post

use the Scripting.FileSystemObject, it has a CreateTextFile method which returns a TextStream object which you can use to write to the newly created file. Example from MSDN:
Sub CreateAfile
   Dim fso, MyFile
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set MyFile = fso.CreateTextFile("c:\testfile.txt", True)
   MyFile.WriteLine("This is a test.")
End Sub

Reply With Quote

Similar Threads
Thread Thread Starter Forum Replies Last Post
Easy One ru1 Access 2 September 15th, 2006 10:36 PM
An easy one for you... pepocles BOOK: Access 2003 VBA Programmer's Reference 0 September 7th, 2006 05:33 PM
Probably easy but... AMP - Max Current BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 2 December 20th, 2004 02:55 PM
NOT Easy Enough!!! wilson Forum and Wrox.com Feedback 3 July 16th, 2004 07:14 PM
This should be easy benibell Javascript 1 June 22nd, 2004 05:50 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.