• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 330
  • Last Modified:

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

   
0
SilverProject090899
Asked:
SilverProject090899
  • 5
  • 4
  • 3
  • +3
1 Solution
 
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
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

 
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
 
SilverProject090899Author Commented:
 
   Thanks a lot .....
0
 
sumant032199Commented:
Thanks a lot for your assessment.
0

Featured Post

Live webcast with Pinal Dave

Pinal Dave will teach you tricks to help identify the real root cause of database problems rather than red herrings. Attendees will learn scripts that they can use in their environment to immediately figure out their performance Blame Shifters and fix them quickly.

  • 5
  • 4
  • 3
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now