Results 1 to 9 of 9

Thread: [RESOLVED] Executing command line tool

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Resolved [RESOLVED] Executing command line tool

    Hi, I have a little problem with a command line tool.

    The command line tool I'm using is par2.exe (par2cmdline). Par2 files are used to check a specific set of rar archives for corruption and to repair them if necessary. This is mainly used in the newsgroups.

    I'm using the following command to execute it with VB6:

    VB Code:
    1. Private Sub Command1_Click()
    2. ShellAndWait (App.Path & "\par2.exe repair -- " & "D:\Files\*.par2"), vbHide
    3. End Sub
    I'm using a wildcard, because I want to check all par2 files in the folder without typing in the name of each par2 file. The problem is that it only checks the first one in the folder (alphabetical order), because it has no batch function.

    For example, I have these par2 files in one folder.

    Code:
    File1.par2
    File24.par2
    something.par2
    testing.par2
    When I execute the above command, then it will only check File1.par2 (and corresponding rar archives) and after that it quits.

    Is there a way to loop through the folder and execute par2.exe on each file until it has checked all of them?

    Thanks.

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Executing command line tool

    VB Code:
    1. Dim tmp As String
    2. tmp = Dir("D:\Files\*.par2")
    3. Do While tmp > ""
    4.     ShellAndWait (App.Path & "\par2.exe repair -- " & "D:\Files\" & tmp), vbHide
    5.     tmp = Dir
    6. Loop
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: Executing command line tool

    That works. Thank you very much.

    There is one more thing.
    The par2 file checks for corruption, but there are also the actual repair files which have a par2 extension. They look like this:

    Code:
    File1.vol000+01.par2
    File1.vol001+02.par2
    File1.vol003+04.par2
    Is there a way to exclude those par2 files (i.e. with *.vol*), because now it uses them to check the rar archives as well. This way the rar archives get checked 4 times.

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Executing command line tool

    VB Code:
    1. Dim tmp As String
    2. tmp = Dir("D:\Files\*.par2")
    3. Do While tmp > ""
    4.     If Instr(tmp,"vol") = 0 Then
    5.         ShellAndWait (App.Path & "\par2.exe repair -- " & "D:\Files\" & tmp), vbHide
    6.     End if
    7.     tmp = Dir
    8. Loop
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: Executing command line tool

    Excellent! Thanks for your help

  6. #6
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Executing command line tool

    no problem

    (Please mark the thread resolved - at the top.. click the thread tools)
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: Executing command line tool

    Ok, I'll do that, but for some reason this won't work if I use a Textbox for the filepath. I'm sure that I'm doing something wrong, but I don't know what it is.

    I've set it to vbNormalFocus to see what happens and the command window pops up several times and that's it.

    VB Code:
    1. Private Sub cmdProcess1_Click()
    2. Dim tmp As String
    3. tmp = Dir(Text1.Text & "\*.par2")
    4. Do While tmp > ""
    5.     If InStr(tmp, "vol") = 0 Then
    6.         ShellAndWait (App.Path & "\par2.exe repair -- " & Chr$(34) & Text1.Text & "\" & Chr$(34) & tmp), vbNormalFocus
    7.     End If
    8.     tmp = Dir
    9. Loop
    10. End Sub

  8. #8
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Executing command line tool

    Don't you want the quote around the whole filename?
    VB Code:
    1. "\"  & tmp & Chr$(34)

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: Executing command line tool

    Thanks, dglienna

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width