How can I have my app open an EXE file?
Printable View
How can I have my app open an EXE file?
You can have it run a file using Shell
'
'using Shell
Shell ("C:\myApp.exe")
That will load it, but not always give it focus.
And the constants are:Code:Shell "App.exe", vbNormalFocus
Code:vbHide
0
Window is hidden and focus is passed to the hidden window.
vbNormalFocus
1
Window has focus and is restored to its original size and position.
vbMinimizedFocus
2
Window is displayed as an icon with focus.
vbMaximizedFocus
3
Window is maximized with focus.
vbNormalNoFocus
4
Window is restored to its most recent size and position. The currently active window remains active.
vbMinimizedNoFocus
6
Window is displayed as an icon. The currently active window remains active.
Better yet, there is an api function that is better than the Shell function called ShellExecute. Use it :rolleyes:.
Code: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
Public Const SW_SHOWNORMAL = 1
Public Const SW_ShowMinimized = 2
Public Const SW_SHOWMAXIMIZED = 3
Public Const SW_Hide = 0
Public Const SW_MAX = 10
Public Const SW_MAXIMIZE = 3
Public Const SW_MINIMIZE = 6
Public Const SW_NORMAL = 1
ShellExecute Me.hwnd, vbNullString, "C:\file.exe", _
vbNullString, "c:\", SW_SHOWNORMAL