1. Faisal Hayat
  2. PowerBuilder
  3. Wednesday, 26 September 2018 10:41 AM UTC

We are using VB script in order to get all the process list of system which was working fine before we tried to use 64 bit executable because vb script is not compatible with 64 bit. The previous code is given below.

 

OleObject mssc
int li_rc, i
string ls_code, ls_res
Any res

mssc = CREATE OleObject
li_rc = mssc.ConnectToNewObject( "MSScriptControl.ScriptControl" )
mssc.language = "VBScript"

ls_code = "function services() ~r~nstrComputer=~".~"~r~nSet objWMIService = GetObject(~"winmgmts:~"" + &
"& ~"{impersonationLevel=impersonate}!\\~" & strComputer & ~"\root\cimv2~")~r~n" + &
"Set colProcesses = objWMIService.ExecQuery(~"select * from win32_process~" )~r~n" + &
"s = ~"~"~r~nFor Each objProcess In colProcesses~r~n" + &
" s = s & objProcess.ProcessId & ~",~"~r~nNext~r~nservices = s~r~nend function"

mssc.AddCode(ls_code)
ls_res = string(mssc.Eval("services()"))

The above code return a string (comma separated) of all the processes IDs.

Can someone help to replace above code for 64 bit, any function of PB or something which can run successfully on 64 bit system.

Accepted Answer
Eduardo G. Accepted Answer Pending Moderation
  1. Friday, 28 September 2018 07:03 AM UTC
  2. PowerBuilder
  3. # Permalink
Comment
  1. Faisal Hayat
  2. Monday, 1 October 2018 09:48 AM UTC
Thanks for your support. It worked for me perfectly.
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Thursday, 27 September 2018 20:07 PM UTC
  2. PowerBuilder
  3. # 1

You can do it fairly easily using Windows API functions directly from your PowerBuilder app. The process is explained here:

https://docs.microsoft.com/en-us/windows/desktop/toolhelp/taking-a-snapshot-and-viewing-processes

 

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 27 September 2018 14:40 PM UTC
  2. PowerBuilder
  3. # 2

Hi Faisal;

   Suggestion:  As a workaround in case you cannot get your approach to work in the 64bit realm ... how about creating a 32bit App that uses your OLE approach but returns the process list to the 64bit calling App of the processes it needs to look at?

Regards ... Chris

Comment
  1. Faisal Hayat
  2. Thursday, 27 September 2018 14:54 PM UTC
That's a good suggestion and would go with it if no other option works.

Definitely I would like to get it working without maintaining a separate application. Please let me know if there is a solution. Thanks
  1. Helpful
  1. Faisal Hayat
  2. Thursday, 27 September 2018 16:33 PM UTC
Hi Chris

Is there anyway that we can check that whether specific process is running or not. May be a a function of PB or some window dll which takes PID as input parameter and returns the result of its existence/running?
  1. Helpful
  1. Chris Pollach @Appeon
  2. Thursday, 27 September 2018 17:04 PM UTC
What about using the "GetProcessId " MS-Windows API?
  1. Helpful
There are no comments made yet.
Faisal Hayat Accepted Answer Pending Moderation
  1. Thursday, 27 September 2018 13:26 PM UTC
  2. PowerBuilder
  3. # 3

Hi Chris,

Thanks for your support. I have looked into provided solution and found that it returns processed IDs of only running windows. Previously shared VB script is returning 209 process IDs while the solution returns only 44. I am looking to get all the process IDs even if these running in background. 

 

 

Comment
  1. Faisal Hayat
  2. Thursday, 27 September 2018 14:29 PM UTC
It displays 659 total processes but if we talk about unique processes these are 44 only while VB code give you 209 unique processes.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Thursday, 27 September 2018 14:37 PM UTC
Ahhh .. Yes, I do not distill the list down to "unique" list of processes. I just list all that I can find in the order that I see them in all the MS-Windows control blocks (RCE's = Resource Control Elements).
  1. Helpful
  1. Faisal Hayat
  2. Thursday, 27 September 2018 14:41 PM UTC
Moreover you are getting PROC IDs on the basis on windows. What to do to get PID of background process?
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 26 September 2018 13:38 PM UTC
  2. PowerBuilder
  3. # 4

Hi Faisal;

  I can do all that in either a native PB 32 or 64 bit App. Have a look at my MS-Windows "Process Explorer" App for code examples.

HTH

Regards ... Chris

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.