-
I am trying to use the shell function to execute a program from my code and I am getting the error file not found, but if I copy the path to the run dialog box it executes the EXE fine. I cannot figure out why this is happening. If anyone can help I would really appreciate it.
Thanks in advance
-
syntax...maybe...
here's an example..let's see your code and your path
Dim RetVal
RetVal = Shell("C:\WINDOWS\notepad.exe C:\WINDOWS\mytext.txt", 1)
-
My Code
This is what my code does:
Code:
shell "C:\Program Files\3dfx\VisualReality\TV\3dTv.exe"
it doesnt work, but I copied it from the shortcut and if I pasted it into the run dialog it executes.
Code:
shell "c:\program files\Microsoft Office\office\winword.exe"
works fine.
I am completely puzzled????
-
..so am I...
Shell "C:\Program Files\Birthday Reporter\birthdays.exe"
this runs my exe from within program files..
check your path...ie..go to your exe through
windows explorer..find your exe and right click to
get it's path and then copy it into your shell
statement...add the pgm.exe to it and it should work.
-
ShellExecute API
Juz use the ShellExecute API is much more better then the ordinally Shell f unction.
Code:
Option Explicit
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 Const SW_SHOWNORMAL = 1
Private Sub Form_Load()
ShellExecute Me.hwnd, vbNullString, <Your FileName Here>, vbNullString, "C:\", SW_SHOWNORMAL
End Sub