Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To 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
 
Old February 14th, 2006, 10:35 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default vbscript question

Hi all,

Not sure where to post this as its a web language but its VB orientated.

I have built a network upgrade app by combining VBScript with the NT4 Resource kit. I am trying at the moment to create a drop down list of available log files. Here's the code:

sub SaveLog(whichLog)

    set sObj = createobject("wscript.shell") 'create activeX shell obj
    serialTime = formatdatetime(now(), vblongdate) 'set up a date
    newdir = "c:\firestone_project\packaged\pastlogs\" 'set new location for file copy
    sObj.run("C:\winnt\system32\cmd.exe /c copy c:\firestone_project\packaged\ghostware-" & whichLog & ".log" & " " & chr(34) & newdir & whichLog & " " & serialTime & ".log" & chr(34) & " > c:\done.txt")'open command and run the copy

This is the easy part. The hard part is telling vbscript to populate a listbox WITHOUT duplicates consisting of all the .log files in the one directory. Here's the code:

    <script language = "vbscript">
    sub getLogs()
    set sObj = createObject("wscript.shell") 'create a shell to use with CMD
set fObj = createObject("scripting.filesystemobject")'Create a file system object
    sObj.run("c:\winnt\system32\cmd.exe /c dir c:\firestone_project\packaged\Pastlogs > c:\firestone_project\packaged\pastlogs\loglist.txt ") 'get DIR of all log files in the directory and output them to a textfile.

    set loglist = fObj.opentextfile("c:\firestone_project\packaged\p astlogs\loglist.txt")'open the textfile
do until loglist.atendofstream 'read it line by line passing each line of text into a select box option element
    theoption = loglist.readline
    set oElement = document.CreateElement("OPTION")
    oElement.text = theoption
    if instr(oElement.text, ".log")<> 0 then
    document.getElementById("selectlog").add oElement
    end if


    loop

    loglist.close


    end sub
    </script>

Whats happening is that every time my routine reads the loglist it duplicates it in the select box. Any ideas?

__________________
\'sync\' &lt;cr&gt;
The name specified is not recognized as an internal or external command, operable program or batch file.





Similar Threads
Thread Thread Starter Forum Replies Last Post
VBScript junedali10 VB How-To 3 September 27th, 2006 03:06 PM
VBSCRIPT pantera710 Classic ASP Basics 3 September 11th, 2006 09:28 PM
Need Help in VBScript ragavendran31 Pro VB 6 0 April 19th, 2006 05:54 AM
vbscript question (not sure where to post this) interrupt Javascript How-To 0 February 14th, 2006 10:38 AM
Question on Pattern matching using VBscript Dereksam VBScript 1 September 9th, 2004 04:45 AM





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