1. Daniel Mullings
  2. PowerBuilder
  3. Friday, 11 June 2021 21:23 PM UTC

Good day.

This is the code in my function:

int num, ret, i
long pid
String ls_query, ls_name
Any process

ls_query = 'select * from Win32_Process where name = "appname.exe"'
locator = CREATE OleObject
ret = locator.ConnectToNewObject("WbemScripting.SWbemLocator");
service = locator.ConnectServer();
props = service.ExecQuery(ls_query);
num = props.count()
pid = props.processid
Messagebox("of_check_sp_running", "count = "+ string(num) + " and pid = "+ string(pid))
return num

num comes back with 0 if appname.exe is not running and > 0 when one or more appname.exes are running.

But I'm looking to get the processid, but it keeps crashing.

Googled and have not found anything that works.

My goal is to download a self extracting install app that will update the current running app.

So, if app123_servicepack.exe is running (because I just downloaded it from a website from appname.exe), terminate appname.exe using similar script above prior to clicking install on app123_servicepack.exe.  I terminate using name in win32_processes, but it kills appname.exe and app123_servicepack.exe as well. 

I'm thinking I can terminate appname.exe by the processid and it will hopefully not terminate app123_servicepack.exe as well.

Thanks for any help anyone can provide.

Roland Smith Accepted Answer Pending Moderation
  1. Saturday, 12 June 2021 22:48 PM UTC
  2. PowerBuilder
  3. # 1

I have a free tool called PBUpdater. The self update processing is built into your application.

The user is prompted at startup to update. Files are downloaded and when the user exits, a vbscript file is generated and executed that copies the files from the temp folder to the install folder.

It comes with an Admin app for uploading files.

You can find it here:

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

 

Comment
  1. Daniel Mullings
  2. Wednesday, 16 June 2021 13:40 PM UTC
Thanks Roland.

I downloaded this module a couple of years back and incorporated it into my app. I modified it to pull the updated software from a table in an Oracle database. Worked great on Windows 7. When our users began migrating to Windows 10, running a vbscript was not allowed and our desktop team was not willing to change that. So I made another modification where it downloads a self extracting installation executable which users are allowed to run. This worked for a while until something changed, a windows update, or a policy somewhere, but when my app calls the self extracting installation exe, it prompts for an administrator password. Yet, the user has permission to run that install app from the downloaded folder, the application does not.

It was suggested by our desktop team to run this command prior to running the install app

(set __COMPAT_LAYER=RunAsInvoker)

I hadn't been too successful getting this to work.
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Saturday, 12 June 2021 01:55 AM UTC
  2. PowerBuilder
  3. # 2

Hi, Daniel -

A few months ago I created a PowerBuilder application that obtains and displays Windows Management Instrumentation (WMI) class properties. The app is available for download in the CodeXchange portion of the Appeon Community. Here's a link to it:

https://community.appeon.com/index.php/codeexchange/powerbuilder/281-wmi-windows-management-instrumentation-class-properties-inspector

The Win32_Process class is available for selection when you choose the "Processes" Class Category

I hope you will find the application helpful in accomplishing your goal.

Best regards,
John Fauss

Comment
  1. Daniel Mullings
  2. Wednesday, 16 June 2021 13:25 PM UTC
Thanks John, I'll downloaded it and will look into it soon.
  1. Helpful
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Friday, 11 June 2021 22:31 PM UTC
  2. PowerBuilder
  3. # 3

I don't know if this will be of any help, but this is the external function call I make in PowerBuilder to get the process id:

// External function declaration
FUNCTION long GetCurrentProcessId ()  LIBRARY "kernel32.dll"

// Called in script:
ll_pid = GetCurrentProcessId ()

I use the process ID and the user ID to create unique file & window names. This allows for multiple users of the application on the same platform.

IS_RUNNING_FILENAME = "<appname>_IS_ACTIVE_<is_user>_<IS_PROCESS_ID>.ACTIVE"

IS_TEMP_TITLE = "<whatever> - " + <userid> + "_" + <process_id>

You can also uniqely name windows using this trick, which makes it easy for the FindWindowW (0, ls_window_title)
function to work.


Comment
  1. Chris Pollach @Appeon
  2. Monday, 14 June 2021 17:44 PM UTC
Hi Olan;



Great suggestion! That is what I also use in my frameworks. They work great!



@Dan here are some external functions that are useful for these sort of O/S inquiries ...

FUNCTION uLong GetCurrentProcess ( ) LIBRARY "KERNEL32.dll"

FUNCTION uLong GetCurrentProcessId ( ) LIBRARY "kernel32.dll"

FUNCTION uLong GetCurrentThread ( ) LIBRARY "KERNEL32.dll"

FUNCTION uLong GetCurrentThreadId ( ) LIBRARY "kernel32.dll"



Regards ... Chris
  1. Helpful
  1. Daniel Mullings
  2. Wednesday, 16 June 2021 13:25 PM UTC
Thanks Olan and Chris, I'll take a look at this.
  1. Helpful
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.