Author Topic: Status of a process  (Read 432 times)

seckner

  • Jr. Member
  • **
  • Posts: 66
Status of a process
« on: April 16, 2018, 11:21:01 am »
I have a program that runs on a server and it has a habit of pausing itself. I'm lost trying to find the "status" of it. When it runs normally it looks like the first picture, everything normal. When it pauses the phrase ***REPORT SERVER PAUSED*** shows up. If I can find it, I can restart the darn thing. Please feel free to beat me as severely as needed. 

td

  • Tech Support
  • *****
  • Posts: 2566
    • WinBatch
Re: Status of a process
« Reply #1 on: April 16, 2018, 11:58:30 am »
Assuming you are referring to a regular Windows service, check out the Network Extender's "wntSvcStatus" function.  You might have to do a little trial and error to get the parameters right.  If you are attempting to query the service remotely, you may need to use the wntRunAsUser with login type 6.
 
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


td

  • Tech Support
  • *****
  • Posts: 2566
    • WinBatch
Re: Status of a process
« Reply #2 on: April 16, 2018, 01:11:54 pm »
If you are not referring to a service managed by the Windows Service Control Manager, you may simply need to look for a window with the title in the posted image.  See WinItemize and WinItemizeEx in the Consolidated WIL Help file.
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


seckner

  • Jr. Member
  • **
  • Posts: 66
Re: Status of a process
« Reply #3 on: April 16, 2018, 02:27:56 pm »
Thank you kind sir, I should have been clearer - this is a process. Service would be fairly easy but this is a exe that runs on the server.

td

  • Tech Support
  • *****
  • Posts: 2566
    • WinBatch
Re: Status of a process
« Reply #4 on: April 16, 2018, 02:32:27 pm »
Not to put to fine a point on it but Windows services are processes too.
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


seckner

  • Jr. Member
  • **
  • Posts: 66
Re: Status of a process
« Reply #5 on: April 16, 2018, 05:14:33 pm »
True. Let's try this - the process does not show up in the services window as a traditional Windows service. The only place I can find it is in the Task Manager. Are you saying that the services functions will work on processes? I'll try that in the morning.

td

  • Tech Support
  • *****
  • Posts: 2566
    • WinBatch
Re: Status of a process
« Reply #6 on: April 16, 2018, 09:56:43 pm »
The service functions only work on processes that are under the control of the Service Control Manager (SCM.)   You will need to use the previously mentioned  Win* functions and/or possibly the AppExist and the TerminateApp functions because your process is not under the control of the SCM.  Alternatively, you could use the FCL's "System.Diagnostics.Process" class which has some convenient features.    There is a simple example here:

http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/dotNet/System_Diagnostics+Kill~a~Process.txt

MSFT's documentation can be found here:

https://msdn.microsoft.com/en-us/library/system.diagnostics.process(v=vs.110).aspx
 
You might be able to use the "MainWindowTitle" property of the class to determine the state of your targetted app.  It all depends on the text in the title changing when your app is paused which seems to be the case based on your graphic.

"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


ChuckC

  • Full Member
  • ***
  • Posts: 153
Re: Status of a process
« Reply #7 on: April 18, 2018, 05:14:39 am »
If the process isn't a native NT service running under control of the SCM, then by definition it must be running in a user session, either on the "console" [console session definition varies with the version of Windows] or in a terminal services session.

In this situation, how is the process started?  Does somebody logon to the server via RDP or the console, double click a shortcut and then leave the session running [possibly in a locked state]?  Is the an entry under the "Run" key in the user's registry hive that automatically starts the process at logon time, again, with the session being left running?  Is the Windows Task Scheduler involved and configured to run the task as a specific user but not within a specific desktop session [e.g. within session #0]?  If so, remember that the task schedule in that case *is* a service process, and it would simply be starting this other process as a child process in session #0.

One thing that you can be certain of is that the process doesn't just automatically start up and run when the server boots up and the process isn't a service process.

td

  • Tech Support
  • *****
  • Posts: 2566
    • WinBatch
Re: Status of a process
« Reply #8 on: April 18, 2018, 01:50:51 pm »
WinBatch is certainly capable of working with the Windows Task Scheduler using the "Schedule.Service" COM Automation object.  There are multiple examples in the Tech Database.   

Some WIL functions are also capable of working with processes in session 0.  The "TerminateApp" function being a case in point.   The "System.Diagnostics.Process" class should also work across sessions but I haven't tried it to confirm this. 
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


td

  • Tech Support
  • *****
  • Posts: 2566
    • WinBatch
Re: Status of a process
« Reply #9 on: April 19, 2018, 07:47:46 am »
Wrote a quick test script that confirms that the FCL's "System.Diagnostics.Process" class can easily access session 0 processes. 

The best way to explore the exact nature of a process is probably System Internal's  Process Explorer.   It will tell you just about everything you could ever want to know about a process. The System Internals toolset is maintained by MSFT and updated frequently so make sure you have the latest version by checking MSFT's site.

https://docs.microsoft.com/en-us/sysinternals/downloads/sysinternals-suite
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates