Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 14th, 2006, 10:38 AM
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("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



    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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question on HTTP Post dgrumbli BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 3 December 20th, 2006 02:03 PM
Old post from a year ago, had question plz galacticsoul General .NET 0 August 4th, 2006 12:01 PM
vbscript question interrupt VB How-To 0 February 14th, 2006 10:35 AM
Question on Pattern matching using VBscript Dereksam VBScript 1 September 9th, 2004 04:45 AM

All times are GMT -4. The time now is 01:54 AM.

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