Solved

Detect that a Dos instance is running

Posted on 2000-05-02
6
242 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
Comment Utility
I forgot to mention I'm running win98 in a 5 station Peer-to-Peer network.
0
 
LVL 3

Expert Comment

by:Dassa
Comment Utility
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
Comment Utility
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
Why do Marketing keep bothering you?

Is your marketing department constantly asking for new email signature updates? Are they requesting a different design for every department? Do they need yet another banner added? Don’t let it get you down! There is an easy way to manage all of these requests...

 
LVL 3

Expert Comment

by:Dassa
Comment Utility
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
Comment Utility
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
Comment Utility
@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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Our Group Policy work started with Small Business Server in 2000. Microsoft gave us an excellent OU and GPO model in subsequent SBS editions that utilized WMI filters, OU linking, and VBS scripts. These are some of experiences plus our spending a lo…
This is an article about Leadership and accepting and adapting to new challenges. It focuses mostly on upgrading to Windows 10.
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…
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.

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now