View Single Post
  #1 (permalink)  
Old February 14th, 2006, 10:38 AM
interrupt interrupt is offline
Friend of Wrox
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default vbscript question (not sure where to post this)

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("") 'create activeX shell obj
    serialTime = formatdatetime(now(), vblongdate) 'set up a date
    newdir = "c:\firestone_project\packaged\pastlogs\" 'set new location for file copy"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("") 'create a shell to use with CMD
set fObj = createObject("scripting.filesystemobject")'Create a file system object"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



    end sub

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.
Reply With Quote