1. Rick Domogalik
  2. PowerBuilder
  3. Friday, 25 March 2022 14:37 PM UTC

I am writing an admin program to check if a certain program is running on all workstations on my network. This will allow an admin to make sure all users have exited a program prior to updates being rolled out.

I can do this with a command prompt and -- tasklist /s computername /fi "imagename eq programIamLookingFor.exe"  
The command prompt returns running or not found.

I have used Topwiz's runandwait code in the past, but this simply returns success or failure and does not show the console output, ie, is the program is running or not.

Anyone know of a way to grab the console output with runandwait or another method of determining if a program is running on network workstation using some api from powerbuilder?

 

Thanks.

 

Rick

Roland Smith Accepted Answer Pending Moderation
  1. Saturday, 2 April 2022 17:37 PM UTC
  2. PowerBuilder
  3. # 1

I rewrote my RunAndWait example. It now can capture console output. It runs the program redirecting the output to a Pipe. Then when the program finishes, it reads the pipe and displays it in a MLE.

https://www.topwizprogramming.com/freecode_runandwait.html

 

Comment
  1. Chris Pollach @Appeon
  2. Monday, 4 April 2022 15:41 PM UTC
Nice Roland!
  1. Helpful
  1. Roland Smith
  2. Monday, 4 April 2022 15:55 PM UTC
I just updated it because it would sometimes hang if the external program doesn't return immediately after the last message was written.
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Friday, 1 April 2022 14:13 PM UTC
  2. PowerBuilder
  3. # 2

Hi, Rick - 

Have you looked at this example in CodeXchange?

https://community.appeon.com/index.php/codeexchange/powerbuilder/57-redirect-console-output#54

I tried it with the Tasklist command (only on my local machine) and it appears to capture the output and the filter option appears to work. The example app redirects stdout to a multiline edit control, but I'm pretty sure this could be easily changed to a DataWindow or DataStore. Worth a look.

Regards, John

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Saturday, 26 March 2022 18:05 PM UTC
  2. PowerBuilder
  3. # 3

There is a way for a PB app to write to the console if run as a 'batch' program. I have used it myself.

https://www.rgagnon.com/pbdetails/powerbuilder-print-to-the-console.html

Here is an example in VB6 of running an external program and capturing its STDOUT using pipes. I haven't tried this. Maybe sometime I can add this to my RunAndWait example.

http://www.vb-helper.com/howto_capture_console_stdout.html

 

Comment
  1. Chris Pollach @Appeon
  2. Monday, 28 March 2022 14:26 PM UTC
Great tip Roland!

FYI: for STD Framework users ... you can use the "of_write_console" method located in the "nc_app_controller_master" (Application Controller) base level ancestor class to perform the DOS Console interactions. ;-)
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Saturday, 26 March 2022 17:55 PM UTC
  2. PowerBuilder
  3. # 4

I would change the app to set the AppName and Host database parms.

You can set Host to the computer's name and AppName to a short version of the application name along with a version number.

Then you can use sp_who or a custom query to see who is connected, what machine they are on, and what version of the app they are running.

Comment
There are no comments made yet.
Brad Mettee Accepted Answer Pending Moderation
  1. Saturday, 26 March 2022 16:05 PM UTC
  2. PowerBuilder
  3. # 5

Have you considered using the database server to see who's still connected? ASA and ASE let you query the database server to see who is connected, and can even retrieve the connection name (which you can set when the app connects to the server). This way you can track if your app has any open connections that need to be closed.

Comment
There are no comments made yet.
Mark Goldsmith Accepted Answer Pending Moderation
  1. Friday, 25 March 2022 19:14 PM UTC
  2. PowerBuilder
  3. # 6

Hi Rick,

You could send the output to a temporary file using something like the following:

String ls_command

ls_command = 'cmd /c tasklist /v /fi "STATUS eq running" > c:\users\rick\desktop\allrunning.txt'
Run(ls_command, Minimized!)

Then process the 'allrunning.txt' file whatever way you want...display in MLE control, import into DW control etc. (or in your case search for the existence of "running" or "not found").

HTH...regards,
Mark

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.