Solved

Detect that a Dos instance is running

Posted on 2000-05-02
6
253 Views
Last Modified: 2013-12-28
I need to detect that a dos program (a compiled Clipper program) is running so I can inhibit a user from loading a second instance. I have tried to do this by testing to see if a specific database file is open but this doesn't work.
0
Comment
Question by:mrl
  • 3
  • 3
6 Comments
 

Author Comment

by:mrl
ID: 2771611
I forgot to mention I'm running win98 in a 5 station Peer-to-Peer network.
0
 
LVL 3

Expert Comment

by:Dassa
ID: 2772954
If you can recompile the program you could have it set an environment variable on startup and clear it when shutdown.  Otherwise you could do the same thing by having the program started from a batch file and using the set command to control the variable.  You could use a test of the variable to decide to run the program or not.  You can do the same thing by having the batch file create a file and delete it when the program is shut down if you would be more comfortable with that idea.
0
 

Author Comment

by:mrl
ID: 2774896
Dassa
I have tried using Batch environment vars and trying to detect files open but I can still run multiple instances of the program. It's as if totally new DOS environment partitions are opened and environment vars are not shared between DOS partitions. (I am using an icon to start the program). I think I need to have win98 forced to open only one DOS environment! If I use Run/Command/name of Bat file.. method to open a dos window the environment var will work but my users want an icon and that's when I have the problem. If I am missing something please tell me.  
0
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

 
LVL 3

Expert Comment

by:Dassa
ID: 2776715
mmm...forgot about Windows running programs in DOS boxes, they each have their own environment space.  Using the file exist test would be the way to overcome this.  If you test in the batch file for the existance of a file in say c:\temp and if it exists, exit the batch file, if it doesn't create it and run your program.  After your program runs, delete the file.  That should overcome the problem.  If it is a network program, you may have to test for the file on a networked drive, so that any user with the icon (batch file startup) for the program can utilise the file test.  If you like I could do you up a sample batch file.

You could also try forcing your batch file to run in MSDOS mode.  The option is found in the properties of the icon, under Program -- Advanced.  If you wish to use the environment approach.  This should stop it from running the program in a DOS box.
0
 

Author Comment

by:mrl
ID: 2779416
Dassa
Thank you for your offer of an example file-test bat file...could I please have that? I have successfully tested doing this in one my clipper programs but I have a hundred or more of these and to recompile that many would be too costly. If I can do it with bat files it would be a lot simpler.
What actually would be the best solution is to stop the user loading the Menu that calls all my progs. This is some old compiled Basic Menu (has BRUN30 with it) that I got as freeware in 1986! It executes from a .Bat calling a (MenuMain.exe) but doesn't show up on the list of running progs in mem /c. Any ideas about inhibiting the running of this program.  Thanks for your continued help. Mal
0
 
LVL 3

Accepted Solution

by:
Dassa earned 100 total points
ID: 2779958
@Echo off
Rem Batch file to only allow one instance of a DOS program to run under Windows
Rem Above line turns off screen echo of batch commands
Echo Starting Program ...  Please wait ......
Rem We now test for the existance of the file.
Rem Be aware, if batch file illegally terminated this may need to be manually deleted.
if exist c:\temp\single.txt goto duplicate
Rem If the file doesn't exist we next create it.
copy c:\sstart.bat c:\temp\single.txt >nul
Rem Now we call the program
call c:\windows\command\edit.com
Rem Now we can delete the file (This is important)
del c:\temp\single.txt > nul
Rem We can exit now.
goto exit
Rem If program is already running post a message
:duplicate
Echo !!!!!!!!!!!!!!!!!!!!!!!!!Warning!!!!!!!!!!!!!!!!!!!!!!!!
Echo .
Echo ################## Program is already running on this system #####################
Echo ################## Program ending .... Contact Administrator #####################
:exit
Echo Program Ended  .....


This is fairly rough.  I used a copy of the batch file itself to create the test file.  You would need to change the paths appropriately etc.  Also, you will need to edit the shortcut for the batch file so that the window is closed automatically when the batch file finishes (program tab on properties).  You may want to add a pause to the :duplicate section at the end so they can see the message.

Tested this with the DOS edit program as indicated in the about text.  Works well :)
0

Featured Post

Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

Question has a verified solution.

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

Suggested Solutions

When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

827 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