Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Windows PID from DOS session

Status
Not open for further replies.

jabhawk2

MIS
May 11, 2007
9
US
I an running scheduled jobs on a Windows server that launch a FPD 2.6 session and there are a few NTVDM sessions that hang. Our process logs say that the jobs all ran to completion but we still have the system processes running and taking up resources.

Some jobs are BAT files and some are direct command line foxpro executable calls.

Is there a was from a FP DOS session to get the Windows PID value? If we write out the value to our log we can quickly identify a dead process.

Thanks
 
NTVDM (NT Virtual DOS Machine) gets loaded any time a 16 bit application is executed. It stays memory resident until you either stop it or reboot, even after the application requiring it has completed.
If you are going to be running that process on a regular basis, it won't hurt to leave NTVDM running. Even though it has used a bit of memroy, it will basically just sit there and do nothing until it is needed again.

To answer your question though, FPD was written to run under DOS, so it wouldn't know anything about Windows. You would have to call an API to get the PID, which from FPD isn't doable without using some other sort of batch file and calling scripting host or some other Windows application. Possibly a VFP app.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
I am agreed that FPD cannot reach out and get the PID nativly but the tasks I have issues with are launched from BAT files.

If I have the process Id of that DOS session I can write it out to a log file within the BAT and use that data to later determine which tasks are not closing out correctly and releasing NTVDM.

What I need is a batch command that will return the PID of the DOS session. Any thoughts????
Jon
 
Well, like I said, using scripting host should work. It can be run from a batch file. (Do a search on Windows Scripting Host or WSH. You will find all sorts of examples)
You could probably keep track of PIDs prior to running your batch processes, then compare with what's running afterward.

But if all you're concerned with is getting rid of those processes, why not use something like "kill" to just kill the running NTVDM processes?

Try this link:




-Dave Summers-
[cheers]
Even more Fox stuff at:
 
You can get hwnd of the window in which runs ntvdm and then you can (i think) read PID using some winapi.
I have the console utility program which can obtain hwnd of active console, but it can not obtain pid. But source code is open :)

It was described here.

If you use it and modify this code for obtain this, pls. send it to me.


Tomas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top