Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 14th, 2006, 10:35 AM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
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.
Reply With Quote
Reply


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
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



All times are GMT -4. The time now is 03:57 AM.


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