Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File does not execute with Shell ("FilePath")

Status
Not open for further replies.

hh2424

Programmer
Feb 18, 2003
37
US
Hi,

I use the following VB code to execute a file
Shell ("FilePath")

When this code executes, I could see a flash in the task bar that it was opened but then immediately exits. I use Windows 2000, does this have anything to do with it? [sadeyes]

thanks,
 
Maybe a bit of debugging is called for. If you put msgboxes before and after each program line you will be able to see how far the program gets before it bails out on you.
 
The program didn't bail. It executes the line, but the file didn't open. It only flashes for a minute and it went away.

 
Try setting the WindowStyle to 1 as in Shell ("FilePath", 1)

By not including it in you Shell command the program will start minimised.

It's not 2000. I use Shell frequently on 2000 and XP machines.

Big Al
 
Thank you all,

I tried setting the window state before but that didn't work either. I found the following code snipplet on the web and it worked.

Public 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


Dim iRetVal As Long

iRetVal = ShellExecute(Me.hwnd, vbNullString, "FilePath", vbNullString, "c:\", 1)
 
hh2424,
not sure if it can be the case but we have experienced following problem:
if working directory for a program (PIF file) set incorrectrly (like, network drive not connected) program just quit in Win 2000.

You could check if you have any settings for path.
 

I use the following VB code to execute a file
Shell ("FilePath")


If FilePath is a variable holding the path of the executable then the quotation marks have turned it into a string. :)
And I believe you do have to put in an absolute path too.

________________________________________________________________________________
You can't put a square peg in a round hole without a lot of force.
If at first you don't succeed get a bigger hammer. - Steve 2003.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top