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
