DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  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&,
    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 DV2001.zip BY120819.txt > PKZip.log
    Erase Hold.tmp
    :Exit


    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
    David



  2. #2
    marc Guest

    Re: .bat file exuted from VB


    David

    This has worked for me

    lnglong = Shell(strZipBatchFile, vbhide)

    Marc


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


Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links