Solved

Detect that a Dos instance is running

Posted on 2000-05-02
6
258 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 
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

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

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

Determining the an SCCM package name from the Package ID
This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
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). …

696 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