DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: .bat file exuted from VB

  1. #1
    David Guest

    .bat file exuted from VB

    I absolutely cannot get a .bat file to execute from VB
    These are the code snippits I've tried:

    strZipBatchFile = Path to my .bat

    Try #1
    Cmd = Environ("ComSpec") & " /c " & strZipBatchFile

    Shell Cmd, vbHide

    Try #2

    Shell strZipBatchFile,vbhide

    Try #3

    Private Declare Function ShellExecuteAny Lib "shell32.dll" _
    Alias "ShellExecuteA" (ByVal hwnd As Long, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As Any, _
    ByVal lpDirectory As Any, _
    ByVal nShowCmd As Long) As Long

    'Run File

    Private Function OpenFile(Cmd As String, strApp As String) As Long

    OpenFile = ShellExecuteAny(Me.hwnd, Cmd, strApp, ByVal 0&, ByVal 0&,

    End Function

    OpenFile "Open",strZipbatchFile

    In none of these instances will VB actuall kick off the .bat file it runs
    the code but nothing happens.

    If I manually dbl-click the .bat file it kicks off perfectly

    My .bat file is created on the fly in VB code writing a .zip file name and
    .txt file name to be zipped with PKZIP

    looks like:

    @echo off
    Copy Hold Hold.tmp
    PKZip -a BY120819.txt > PKZip.log
    Erase Hold.tmp

    Like I said manually kicking the .bat file works perfect... but getting it
    to activate from VB it's like it's being ignored....

    Thanks in advance

  2. #2
    marc Guest

    Re: .bat file exuted from VB


    This has worked for me

    lnglong = Shell(strZipBatchFile, vbhide)


    >I absolutely cannot get a .bat file to execute from VB
    >These are the code snippits I've tried:
    >strZipBatchFile = Path to my .bat

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
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

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