From: NadCixelsyd on
I tend to do just about everything from a DOS window.

I call my VB (5.0) application from DOS. Under certain circumstances,
I wish to exit the VB application in a different directory. My VB
program issues the ChDir statement, but when I end the program and go
back to DOS, the DOS directory has not changed. Is there a way to do
this?
From: ralph on
On Tue, 13 Apr 2010 05:58:15 -0700 (PDT), NadCixelsyd
<nadcixelsyd(a)aol.com> wrote:

>I tend to do just about everything from a DOS window.
>
>I call my VB (5.0) application from DOS. Under certain circumstances,
>I wish to exit the VB application in a different directory. My VB
>program issues the ChDir statement, but when I end the program and go
>back to DOS, the DOS directory has not changed. Is there a way to do
>this?

No

The, miss-named, "DOS Window" or "DOS Prompt" is not "DOS" it is a
Windows Console application which runs an instance of "cmd" or
"command" (depending on how it is invoked).

When you launch a program from this application you essentially get a
copy of the current environment. Any changes made to that environment
only effect the environment of the current instance or of any
additional applications that may be launched - ie, the additional apps
get a copy of the new altered environment.

You might be able to come up with some kind of Rube Goldberg
contraption that signals on exit to restart a new "DOS Prompt" <g>

-ralph
From: dpb on
NadCixelsyd wrote:
> I tend to do just about everything from a DOS window.
>
> I call my VB (5.0) application from DOS. Under certain circumstances,
> I wish to exit the VB application in a different directory. My VB
> program issues the ChDir statement, but when I end the program and go
> back to DOS, the DOS directory has not changed. Is there a way to do
> this?

In short, no...

--
From: Patrice on
Hi,

> My VB
> program issues the ChDir statement, but when I end the program and go
> back to DOS, the DOS directory has not changed.

The issue here is that the current directory is not something global to the
whole OS but specific to each application so your VB app has its own current
directory and the prompt window has also its own distinct current directory
which are not tied in any way...

> Is there a way to do this?

Perhaps calling your VB app from a command file. Then the command file could
perhaps test for the exit code and go to a particular directory depending on
this code...

The context could help (for example you could use subst to map a drive to
the particular location you are interested into or try just to suppress the
need for this directory change).


--
Patrice




From: Karl E. Peterson on
NadCixelsyd wrote:
> I tend to do just about everything from a DOS window.
>
> I call my VB (5.0) application from DOS. Under certain circumstances,
> I wish to exit the VB application in a different directory. My VB
> program issues the ChDir statement, but when I end the program and go
> back to DOS, the DOS directory has not changed. Is there a way to do
> this?

I wrote an "enhanced chdir" console app that calls the directory picker
dialog, allowing you to choose where to go to. It "works" by stuffing
the console keyboard buffer with the appropriate "cd [path]" and (if
needed) drive change commands just prior to terminating. You can do
this with a call to WriteConsoleInput, after building the appropriate
buffer. The results will be visible to the user, of course. But it's
not otherwise doable, for the reasons Ralph first offered.

--
..NET: It's About Trust!
http://vfred.mvps.org


 |  Next  |  Last
Pages: 1 2
Prev: formattting numbers
Next: MSFlexgrid Scrolling