Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Detect that a Dos instance is running

Posted on 2000-05-02
6
Medium Priority
?
265 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
Windows Server 2003 introduced persistent Volume Shadow Copies and made 2003 a must-do upgrade.  Since then, it's been a must-implement feature for all servers doing any kind of file sharing.
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

782 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