1. Faisal Hayat
  2. PowerBuilder
  3. Wednesday, 26 September 2018

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
Comment
Thanks for your support. It worked for me perfectly.
  1. Faisal Hayat
  2. Monday, 1 October 2018
There are no comments made yet.
  1. Friday, 28 September 2018
  2. PowerBuilder
  3. # Permalink
Roland Smith Accepted Answer Pending Moderation
0
Votes
Undo

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.
  1. Thursday, 27 September 2018
  2. PowerBuilder
  3. # 1
Chris Pollach Accepted Answer Pending Moderation
1
Votes
Undo

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
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. Faisal Hayat
  2. Thursday, 27 September 2018
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. Faisal Hayat
  2. Thursday, 27 September 2018
What about using the "GetProcessId " MS-Windows API?
  1. Chris Pollach
  2. Thursday, 27 September 2018
There are no comments made yet.
  1. Thursday, 27 September 2018
  2. PowerBuilder
  3. # 2
Faisal Hayat Accepted Answer Pending Moderation
0
Votes
Undo

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
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. Faisal Hayat
  2. Thursday, 27 September 2018
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. Chris Pollach
  2. Thursday, 27 September 2018
Moreover you are getting PROC IDs on the basis on windows. What to do to get PID of background process?
  1. Faisal Hayat
  2. Thursday, 27 September 2018
There are no comments made yet.
  1. Thursday, 27 September 2018
  2. PowerBuilder
  3. # 3
Chris Pollach Accepted Answer Pending Moderation
0
Votes
Undo

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.
  1. Wednesday, 26 September 2018
  2. PowerBuilder
  3. # 4
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.