running dos command thru VB6


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 12 of 12

Thread: running dos command thru VB6

  1. #1
    Asawari Teredesai Guest

    running dos command thru VB6


    Hello,
    I wish to run dos command 'pkzip' to zip file and 'pkunzip' to unzip file.
    These commands will have 2 parameters , first the "to be zip file name" and
    the second is "file to be zipped".
    i tried that using shell command like
    a = shell(app.path & "\pkzip.exe" & " " & app.path & "\abc.zip" & " " &
    app.path & "\abc.mdb"

    this does not flash error, but doesnot give result also.
    at command prompt, this works. but no result in VB.
    Plz suggest some solution.
    Thanks in advance.

    -Asawari


  2. #2
    Phil Weber Guest

    Re: running dos command thru VB6

    > a = shell(app.path & "\pkzip.exe" & " " & app.path & _
    > "\abc.zip" & " " & app.path & "\abc.mdb"


    Asawari: The code you posted is missing a closing parenthesis, so it will
    generate an error if you try to compile it.

    I would suggest assigning the concatenated string to a variable, e.g.:

    sCmd = App.Path & "\pkzip.exe" & " " & App.Path & _
    "\abc.zip" & " " & App.Path & "\abc.mdb"

    Then you can Debug.Print sCmd and make sure it says what you think it does.
    ---
    Phil Weber



  3. #3
    Phil Weber Guest

    Re: running dos command thru VB6

    > Did not work. plz suggest something else at the earliest.

    I'm sorry, the above response provides no information that might help us
    solve the problem.

    Why don't you post the exact command line you're passing to the Shell
    function?
    ---
    Phil Weber



  4. #4
    Asawari Guest

    Re: running dos command thru VB6


    Hi,
    Didnot work. plz sugegst something else at the earliest.



    "Phil Weber" <pweber@nospam.fawcette.com> wrote:
    > > a = shell(app.path & "\pkzip.exe" & " " & app.path & _
    > > "\abc.zip" & " " & app.path & "\abc.mdb"

    >
    >Asawari: The code you posted is missing a closing parenthesis, so it will
    >generate an error if you try to compile it.
    >
    >I would suggest assigning the concatenated string to a variable, e.g.:
    >
    > sCmd = App.Path & "\pkzip.exe" & " " & App.Path & _
    > "\abc.zip" & " " & App.Path & "\abc.mdb"
    >
    >Then you can Debug.Print sCmd and make sure it says what you think it does.
    >---
    >Phil Weber
    >
    >



  5. #5
    Asawari Guest

    Re: running dos command thru VB6


    A = Shell(App.path & "\pkzip.exe" & " " & App.path & _
    "\CT222.zip" & " " & App.path & "\Con_Tech.mdb")

    this didnot work. gives no error. but does not zip the file.



    "Phil Weber" <pweber@nospam.fawcette.com> wrote:
    > > Did not work. plz suggest something else at the earliest.

    >
    >I'm sorry, the above response provides no information that might help us
    >solve the problem.
    >
    >Why don't you post the exact command line you're passing to the Shell
    >function?
    >---
    >Phil Weber
    >
    >



  6. #6
    Phil Weber Guest

    Re: running dos command thru VB6

    > A = Shell(App.path & "\pkzip.exe" & " " & App.path & _
    > "\CT222.zip" & " " & App.path & "\Con_Tech.mdb")


    Asawari: I've already seen your code; I want to see the result of the above
    concatenation. As I suggested originally, assign the result of the above to
    a variable, and post the value of that variable:

    Dim sCmd As String
    sCmd = App.Path & "\pkzip.exe" & " " & App.Path & _
    "\CT222.zip" & " " & App.Path & "\Con_Tech.mdb"

    ' Now, what is the value of sCmd?

    ---
    Phil Weber



  7. #7
    Rick Rothstein Guest

    Re: running dos command thru VB6

    > A = Shell(App.path & "\pkzip.exe" & " " & App.path & _
    > "\CT222.zip" & " " & App.path & "\Con_Tech.mdb")
    >
    > this didnot work. gives no error. but does not zip the file.


    Do you **really** have pkzip INSTALLED in your application's directory?
    That seems unlikely to me. Try prefacing the "\pkzip.exe" with the
    actual directory where pkzip is installed.

    Rick


  8. #8
    Asawari Guest

    Re: running dos command thru VB6


    yes,
    i installed in application's directory.
    but shell is not useful for me as it requires absolute path in parameter
    and i can't give that in program. i require app.path...

    "Rick Rothstein" <rickNOSPAMnews@NOSPAMcomcast.net> wrote:
    >> A = Shell(App.path & "\pkzip.exe" & " " & App.path & _
    >> "\CT222.zip" & " " & App.path & "\Con_Tech.mdb")
    >>
    >> this didnot work. gives no error. but does not zip the file.

    >
    >Do you **really** have pkzip INSTALLED in your application's directory?
    >That seems unlikely to me. Try prefacing the "\pkzip.exe" with the
    >actual directory where pkzip is installed.
    >
    >Rick
    >



  9. #9
    Asawari Guest

    Re: running dos command thru VB6


    sCmd will give me a number which should be greater than zero to indicate successful
    execution of shell command.
    but shell is not useful for me as it requires absolute path in parameter
    and i can't give that in program. i require app.path.
    i'll search for some other way.
    thanks for ur help.



    "Phil Weber" <pweber@nospam.fawcette.com> wrote:
    > > A = Shell(App.path & "\pkzip.exe" & " " & App.path & _
    > > "\CT222.zip" & " " & App.path & "\Con_Tech.mdb")

    >
    >Asawari: I've already seen your code; I want to see the result of the above
    >concatenation. As I suggested originally, assign the result of the above

    to
    >a variable, and post the value of that variable:
    >
    > Dim sCmd As String
    > sCmd = App.Path & "\pkzip.exe" & " " & App.Path & _
    > "\CT222.zip" & " " & App.Path & "\Con_Tech.mdb"
    >
    > ' Now, what is the value of sCmd?
    >
    >---
    >Phil Weber
    >
    >



  10. #10
    Phil Weber Guest

    Re: running dos command thru VB6

    > sCmd will give me a number which should be greater than
    > zero to indicate successful execution of shell command.


    Asawari: Please re-read my previous message carefully. I'm not talking about
    assigning the return value of the Shell function to a variable; I asked you
    to assign the result of the string concatenation (everything you currently
    have between the parentheses following "Shell") to a variable, and post the
    value of that variable.

    I suspect that App.Path may not be returning the value you think it is.
    ---
    Phil Weber



  11. #11
    Asawari Guest

    Re: running dos command thru VB6


    Hi,
    I got the another way to do this. I created a .bat file to execute DOS commands.
    Thanks for ur help.


  12. #12
    Randy Birch Guest

    Re: running dos command thru VB6

    And in doing so you never solved, therefore never understood, what your
    problem really was. <sigh>

    --

    Randy Birch
    MVP Visual Basic
    http://www.mvps.org/vbnet/
    Please respond only to the newsgroups so all can benefit.


    "Asawari" <asawari_t@rediffmail.com> wrote in message
    news:3d243093$1@10.1.10.29...
    >
    > Hi,
    > I got the another way to do this. I created a .bat file to execute DOS

    commands.
    > Thanks for ur help.
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center