|
-
September 15th, 2001, 03:56 AM
#1
run .bat from VB
I want to run a .bat file from VB.
I am able to run a .exe file by the "Shell" function.
But this function doesnot succeed for .bat for me.
So how to run a .bat file ????
3. Excellent! Aasher.
2. Useful Dear.
1. Good Hint, Thanks.
-1. Hey, I think you did not understand me.
-
September 15th, 2001, 04:43 PM
#2
Re: run .bat from VB
You can use the ShellExecute API function. Here is a small sample.
Start a new project. Add a command button.
Paste this code into the general declaration section of the form.
ALTER the sFileName variable to point to your .BAT file,
run the program and
click the command button.
'
' Add a command button to a form and copy this code into
' the forms general declaration section.
'
'
option Explicit
private Const SW_SHOW as Integer = 5
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()
Dim lrc as Long
Dim sFilename as string
' change following to point to your .CHM file
sFilename = "C:\VB Stuff\HtmlHelp Tutorial\HTML Sample\MyHtml Help.chm"
lrc = ShellExecute(me.hwnd, "open", sFilename, vbNullString, CurDir$, SW_SHOW)
End Sub
John G
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|