Ping Barry Gilbert

I

Isissoft

Barry you were kind enough to help me with a ShellExecute Function - I was
trying to run a program from a shortcut from Access - the reason that I
wanted to do this was to open the program in a defined folder and a
shortcut gives you the option to specify a 'Start In' folder - However, I
fins that although I can call the program using the shortcut, the program
opens in the same folder that the access database is in.

Do you have any further information on how I might proceed ?

Thanks again for the original advice - it has come in useful for other
things already.

Regards
 
T

Terry Kreft

Have you tried using ChDir before your shellexecute call in order to change
the folder?
 
B

Barry Gilbert

Reply from Barry Gilbert bytes=32 time=200ms TTL=51
Reply from Barry Gilbert bytes=32 time=168ms TTL=51
Reply from Barry Gilbert bytes=32 time=192ms TTL=51
Reply from Barry Gilbert bytes=32 time=201ms TTL=51


I'm not sure why the Start In Folder option isn't being picked up, but I
think Terry's suggestion is worth a try.

Barry
 
B

Barry Gilbert

A little research reveals this possibility:

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


ShellExecute 0, "OPEN", "c:\MyDb.lnk", "", "C:\MyStartInFolder\", 1

The second from last parameter is supposed to indicate the default
directory. This might do the trick. If this does work, you might be able to
get away with bypassing the shortcut and going directly to the executable.

Barry
 
I

Isissoft

=?Utf-8?B?QmFycnkgR2lsYmVydA==?=
A little research reveals this possibility:

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


ShellExecute 0, "OPEN", "c:\MyDb.lnk", "", "C:\MyStartInFolder\", 1

The second from last parameter is supposed to indicate the default
directory. This might do the trick. If this does work, you might be
able to get away with bypassing the shortcut and going directly to the
executable.

Barry

Thank you all for your answers.

Barry - I did figure out the parameters from your function but
unfortunately I always get an 'access denied' when using the folder
parameter - I don't think this is possible as I am tsting using the
administrators account and everything is running locally.

The ChDir option sounds possible and I will give it a go.

Thanks again all.

Regards
 
I

Isissoft

=?Utf-8?B?QmFycnkgR2lsYmVydA==?=
A little research reveals this possibility:

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


ShellExecute 0, "OPEN", "c:\MyDb.lnk", "", "C:\MyStartInFolder\", 1

The second from last parameter is supposed to indicate the default
directory. This might do the trick. If this does work, you might be
able to get away with bypassing the shortcut and going directly to the
executable.

Barry


Just a follow up - I was using the wrong position for the folder
parameter - retesting shows that while the folder fails when calling the
shortcut it does seem to succeed when calling the executable directly.

Thank you to everyone who helped me get there.

Regards again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top