hi,pls help this newly member here.
How to open .bat files using VB.
(similar as manually double clicking the batch file in the C directory explorer)
thanx!
Printable View
hi,pls help this newly member here.
How to open .bat files using VB.
(similar as manually double clicking the batch file in the C directory explorer)
thanx!
Use the Shell function.
Code:Shell "C:\MyBatch.bat",vbNormalFocus
i tried your code, but still not responsed.
the idea to execute the batch file is to send a signal command to COM1 port & this command is written in a text file.& the batch file used to copy the text file to COM1.
This signal is to kick out the cash drawer machine.
I tried double click the 1.bat & it's works
??? how to put it into VB?
There appears to be nothing wrong with Matthew's code. Perhaps you can try to shell something else first.
This should start up calculator.Code:Shell "C:\Windows\Calc.exe", vbNormalFocus
Sunny
Hi shwan, may be you can try to use this code, & I've test it. It work as what you ask for.
Code:Option Explicit
Private Const SW_HIDE = 0
Private Const SW_SHOWNORMAL = 1
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub Command1_Click()
'To execute the batch file with loading the MS-Dos Command window
ShellExecute Me.hwnd, vbNullString, "C:\MyBatch.bat", vbNullString, "C:\", SW_SHOWNORMAL
'To execute the batch file without loading the MS-Dos Command window
ShellExecute Me.hwnd, vbNullString, "C:\MyBatch.bat", vbNullString, "C:\", SW_HIDE
End Sub
hi,it's works...finally!
thanx everyone!