Link to home
Start Free TrialLog in
Avatar of SilverProject090899
SilverProject090899

asked on

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....

   
Avatar of jkr
jkr
Flag of Germany image

What do you mean? Do you want to know whether your application is a console program?
Avatar of rs_hebbar
rs_hebbar

Your question is not clear about what you want to do?
Pls give more info!
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.
Avatar of SilverProject090899

ASKER

Edited text of question.
Is that you want to detect that Turbo Pascal is running?
What OS are we talking, this is still Dos16?
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

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 ;)
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;
}


   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 .....        





 

   
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.
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
ASKER CERTIFIED SOLUTION
Avatar of sumant032199
sumant032199
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
 
   Thanks a lot .....
Thanks a lot for your assessment.