|
-
Dec 12th, 2002, 02:05 PM
#1
Thread Starter
Addicted Member
Shell Command and App.Path
Hello,
I'm trying to invoke from my program another VB program that's in an EXE file using the Shell command. The problem is that this program needs to refer to an Access database using App.Path, and if I run it using Shell, it tries to refer to a different directory than the one it would refer if I run it by just clicking the file in the windows explorer. The result is that it can't find the database when I use Shell because it's in a different directory.
How can I cause Shell not to change the directory or get the same result in another way?
Thanks very much.
-
Dec 12th, 2002, 02:25 PM
#2
Addicted Member
Suggestion:
Change the current directory in the application executing "SHELL" to the same directory that the shelled program is in.
Some days you're the dog,
and some days you're the hydrant.
VB6 Enterprise
-
Dec 12th, 2002, 02:28 PM
#3
Re: Shell Command and App.Path
Originally posted by Forest Dragon
Hello,
I'm trying to invoke from my program another VB program that's in an EXE file using the Shell command. The problem is that this program needs to refer to an Access database using App.Path, and if I run it using Shell, it tries to refer to a different directory than the one it would refer if I run it by just clicking the file in the windows explorer. The result is that it can't find the database when I use Shell because it's in a different directory.
How can I cause Shell not to change the directory or get the same result in another way?
Thanks very much.
ok this sounds kinda of confusing.. but are you saying if you have 2 apps
C:\appdir1\app1.exe
C:\appdir2\app2.exe
and in app1 you do
shell "C:\appdir2\app2.exe"
that it makes app2's app.path show "C:\appdir1"?????
-
Dec 12th, 2002, 02:59 PM
#4
Addicted Member
Not exactly...
What you do in the main program is this:
VB Code:
Dim sRemotePath as String
' configure the sRemotePath to be the path of the shelled app
sRemotePath = "C:\Remote App Path"
' now change the current working directory
ChDir = sRemotePath
' now shell your app
SHELL "My Remote App.EXE"
I hope it works!
Some days you're the dog,
and some days you're the hydrant.
VB6 Enterprise
-
Dec 12th, 2002, 03:02 PM
#5
Re: Not exactly...
Originally posted by PhilRob56
What you do in the main program is this:
VB Code:
Dim sRemotePath as String
' configure the sRemotePath to be the path of the shelled app
sRemotePath = "C:\Remote App Path"
' now change the current working directory
ChDir = sRemotePath
' now shell your app
SHELL "My Remote App.EXE"
I hope it works!
what about if a 3rd party program is being used as well and changes the current directory.. you can't plan for that kind of stuff...
-
Dec 12th, 2002, 04:27 PM
#6
Addicted Member
I agree.
Some days you're the dog,
and some days you're the hydrant.
VB6 Enterprise
-
Dec 12th, 2002, 04:59 PM
#7
Thread Starter
Addicted Member
PhilRob56:
I have already tried something similar to your code and unfortunately it didn't work, but thanks anyway.
kleinma:
My problem is that the program invoked using the Shell command refers to an Access database using App.Path. If I run it by just clicking the file from the Windows Explorer, this path will be the real path of the file and so the database will be found because it was put there before. However, if I invoke it using the Shell command, the path that App.Path refers to is not the current path of the program and not the path of the database too, so it cannot be found.
Does anyone have an idea?
-
Dec 12th, 2002, 05:09 PM
#8
Addicted Member
Does the Shelled program support Command Line parameters? If so perhaps the path to the DB can be added to the Shell string....
Also, I wonder what the App.Path is for the Shelled program. If we can find out what it defaults to when Shelled, then maybe there's a way to set it using the API.
Some days you're the dog,
and some days you're the hydrant.
VB6 Enterprise
-
Dec 12th, 2002, 05:15 PM
#9
Addicted Member
MS KB Article.
I see that the ShellExecute API allows you to specify the default directory.
Perhaps it's worth a look?
http://support.microsoft.com/default...b;en-us;170918
Some days you're the dog,
and some days you're the hydrant.
VB6 Enterprise
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|