• C

DOS Prompt

  I want to make a program that can detect if we're in dos prompt while a / several program(s) running.
 
   Example : Assume that i'm running Turbo Pascal ( in it's IDE ) then i want to run a batch file, of course i use DOS Shell menu ( in File pop up menu ). Then i'm now in dos prompt , right ?

    I want to make a tiny program which can only executed on dos prompt ( a validation !). So, can you give me an idea how to make a code in C which can detect if we are in dos prompt or not ....

Any body can help me ?

Thanks....

   
SilverProject090899Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jkrCommented:
What do you mean? Do you want to know whether your application is a console program?
0
rs_hebbarCommented:
Your question is not clear about what you want to do?
0
rbrCommented:
Pls give more info!
0
Powerful Yet Easy-to-Use Network Monitoring

Identify excessive bandwidth utilization or unexpected application traffic with SolarWinds Bandwidth Analyzer Pack.

KangaRooCommented:
Can you tell a bit more? Basically the programm itself determines if its a console or gui application. Note that even that distinction (console - gui) can not always be made.
0
SilverProject090899Author Commented:
Edited text of question.
0
KangaRooCommented:
Is that you want to detect that Turbo Pascal is running?
What OS are we talking, this is still Dos16?
0
sumant032199Commented:
Whenever you are in Windows environment
there is an environmental variable
%windir%="C:\WINDOWS" (majority times)
if this variable is set then Windows is running, can be taken as granted. You can easily get the stored value of this environmental variable.

Following is a very simple BAT file which changes its behaviour depending upon Windows.

Rem A.BAT
@echo off
if "%windir%!"=="!" edit c:\autoexec.bat
if not "%windir%!"=="!" notepad c:\autoexec.bat

0
KangaRooCommented:
It is possible for a batch file to check whether a specific module (or program) is loaded, at least in DOS. You can even find out if a mouse driver is loaded, or smartdrv....
And it is rediculously simple ;)
0
sumant032199Commented:
This is the code.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
   char windir[30];

   strcpy(windir,getenv("windir"));
   if(windir[0]=='\x0') printf("\nWindows is not working.\n");
   else printf("\nWindows is working.\nWindir = %s\n",windir);

   return 0;
}

0
SilverProject090899Author Commented:

   Thanks Sumant for your answer, sorry i didn't give a full description 'bout my problem...

  I want to make a tiny TSR program under dos(16) which can search file(s) in any available drive..i use TSR because i want to make this program can be easily accessed at any path without change path or close any program.

  Well...i had tried to make a hot key to activate it....but i'm afraid it can conflict with any program which is still running...

   Example i'm using Turbo pascal and i want to activate my program. Can it conflicts or efects the current program which is still running ( efects turbo pascal ) ?
 
   My idea is to make this program only can be activated when user is in DOS Prompt ( by typing it's name ).

   Do you have sugestion to make this program can be easier accessed ?

   Thanks a lot .....        





 

   
0
KangaRooCommented:
You should not install a TSR when shelled out from another program. You should install it as TSR before starting Turbo Pascal.
Can't you use doskey and define a macro
  doskey fs=c:\mytools\fast\bin\fsearch $*
Doskey could be run with a macro file.
0
KangaRooCommented:
If you want a batch to detect if a specific module is in memory:

@echo off
  if exist %1 goto isfile
  if exist %1\nul goto isdir
  mem /m %1 | find /i "%1 is using" > nul
  if errorlevel 1 goto nope
:module
  echo module %1 found
  goto end
:nope
  echo %1 not found
  goto end
:isfile
  echo file %1 found
  goto end
:isdir
  echo directory %1 found
:end
0
sumant032199Commented:
Its ok.
As I know when DOS is waiting for an input at DOS prompt DOS idle interrupt 0x28 (I think) is generated periodically.(If you want details about this write a comment.) This is only at DOS prompt. You can construct a TSR which captures this interrupt. You can ensure that it will pop up only at DOS prompt.

Also you need not worry if the TSR pops up while an application like Turbo Pascal IDE is running. Care can be taken so that it doesn't crash the program.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SilverProject090899Author Commented:
 
   Thanks a lot .....
0
sumant032199Commented:
Thanks a lot for your assessment.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.