When I try to run a file with the Shell Function, I get an error message. Apparently, I cannot find the rest of the app. What's wrong
Printable View
When I try to run a file with the Shell Function, I get an error message. Apparently, I cannot find the rest of the app. What's wrong
Open a program (EXE) or a document (BMP, DOC, JPG, etc.)?
A program (with the EXE extension). The problem is that the program has to load an .ini file in that very same directory. But the program cannot find that file when the directory is set to my app. How can I change that. I know there's a way...
Post the code giving the problem and the exact error.
VB Code:
Private Sub Form_Load() Me.Show Label1.FontBold = True Shell "C:\PunkBuster\PB.exe", vbNormalNoFocus Label1.FontBold = False End Sub
Dette er koden
Obviously, I don't have your "C:\PunkBuster\PB.exe" to test but I tried several different applications. Small to large to see if maybe a timing problem. All worked fine.
Nothing wrong with that code.....The PB.exe file runs ok on it's own ??
No, that's the problem. It requires the Pb.ini file. When I run the file from my app, the program Pb.exe does'nt understand to look for it in the PB.exe directory.
VB Code:
ChDir "C:\PunkBuster"
or you could use the shellexecuteex api
But that makes it a whole lot more complicated(Which I don't want, especially since I've never used or done any API...I don't even yet know what it is and what it's used for)
But thanks anyway!
Before you open the .ini file, use ChDir to change to its directory, whatever that may be.
Yes, I know. Thank you
well i was just wondering whether it solved your problem...
ShellExecute is not complicated at all.
Just put this under General Declarations:
It may seem long, but you can just copy & paste it in there.VB Code:
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
Next, put this to replace your current Form_Load() event:
VB Code:
Private Sub Form_Load() Me.Show Label1.FontBold = True ShellExecute hwnd, "open", "C:\PunkBuster\PB.exe", "", "", 1 Label1.FontBold = False End Sub