?
Solved

Getting DOS session to automatically close

Posted on 1997-11-12
10
Medium Priority
?
230 Views
Last Modified: 2013-11-19
I'm trying to get a DOS session to close automatically in Win95, without having to set anything special in Win95 itself. Other programs do this very nicely but I haven't been able to find out how though the VC++ 5 docs. I'm currently using ShellExecute() for this purpose. I'd also like to know how to get that DOS session to remain invisible without having to resort to an invisible window setting.

Thanks in advance for your help!

RJV
0
Comment
Question by:RJV
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 

Author Comment

by:RJV
ID: 1309867
Adjusted points to 100
0
 
LVL 3

Accepted Solution

by:
Jackie071497 earned 800 total points
ID: 1309868
Try to use ShellExecute("Command.com /c ftp.exe") if you want to
ftp.exe in DOS session.
/c is auto close.

0
 
LVL 3

Expert Comment

by:Jackie071497
ID: 1309869
Hi Jackie,

That's an interesting solution. However, I keep getting this error:

    Specified COMMAND search directory bad

The path (to a batch file in this case) is ok, so this is somewhat perplexing. Meanwhile, how will things fare in the NT environment, seeing as it doesn't have a command.com?

RJV

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:RJV
ID: 1309870
Can you post up your commands and batch file contents?
Do you give the full path in commands?
What is your DOS path? ( You can get it by typing "set" in DOS session )

0
 
LVL 3

Expert Comment

by:Jackie071497
ID: 1309871
This works but doesn't close:

  ShellExecute(NULL,NULL,prog,flnm+" "+cmds,wrkPath,show);

Where:

      prog = "c:\project\temp\batch.bat"
      flnm = blank
      cmds = blank
      workPath = blank
      show = (can be normal, minimzed or hide)

This gets the error without even opening the batch file itself (seen after removing the /c):

     prog = "command.com /c c:\project\temp\batch.bat"

Note that command.com is in the path (see below) and I've tried the above giving the specific path and even at the DOS prompt itself, with the same error. Here's the applicable parts of the evironment:

    winbootdir=C:\WINDOWS
    COMSPEC=C:\COMMAND.COM
    PATH=C:\WINDOWS;C:\WINDOWS\COMMAND

Though it never opens the batch file itself, here are its contents, which work without command.com:

   Arj a c:\work\add\test.arj c:\work\test.txt
   Arj a c:\work\add\test.arj c:\work\test1.txt

Hopes this helps! Also thanks for the extra help. I plan to increase the points as it's nice to be able to make up for extra help given for those that do make the effort.

Regards,
RJV

0
 

Author Comment

by:RJV
ID: 1309872
Try to run "command.com /kc:\project\temp\batch.bat"
If it succeed, then turn it to "command.com /cc:\project\temp\batch.bat"

0
 
LVL 3

Expert Comment

by:Jackie071497
ID: 1309873
Jackie, have you tried the command.com solution under VC++? I didn't get back earlier as today I decided to go after this and, no matter what I did, no luck. Everything works fine, but without closing the DOS session, as long as run on its own. It appears as if shelling puts you under command.com and then it doesn't like the extra command.com.

The main problem is to get the DOS session to close automatically under Win95 which stubbornly won't collaborate so far.

Regards,
Roger

0
 

Author Comment

by:RJV
ID: 1309874
You should run the "command.com /cc:\project\temp\batch.bat" under Win95 [Start] --> [Run].
If you run it under DOS session, it will need exit twice.
Because DOS session is another command.com, you know.

I use the command.com solution under VC++ exactly.
But I am using the CreateProcess() instead of ShellExecute().
I don't know what is the difference about running command.com

0
 
LVL 3

Expert Comment

by:Jackie071497
ID: 1309875
Now we're getting a bit closer in coding. I was actually using CreateProcess() plus ShellExecute(). I use the former to wait for an app to finish. Exactly how do you set up CreateProcess? I'll do the same here so we may nail this down.

As to two DOS sessions, I only tried it with a command line to try and find the problem. However, I believe when you launch a DOS program you automatically launch a DOS session, so maybe by using command.com you may indeed get two of them. I could be wrong on that one, though.

RJV

0
 

Author Comment

by:RJV
ID: 1309876
Jackie,

Just to note that I got CreateProcess() to work, finally. The problem is that command.com did not recognize the path given (why I don't know, as it seems to take itself back to PC or MS/DOS version 1). I made our application change to the correct path/folder and then run the batch file and all was ok.

Now I just need to find out if the operating system is Win95 or NT to switch command.com and cmd.exe accordingly. Any tips would be greatly appreciated! As indicated, I've increased the points for your extra effort, which was vital for the solution of my problem.

RJV

0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month10 days, 19 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question