1. John Raghanti
  2. PowerBuilder
  3. Monday, 17 February 2020 13:07 PM UTC

Hi. We're running PB2019. We're having trouble with the built in PB RUN() function.

In one place, for example, we call out to a C# executable to do some external processing.

ls_command = '"' + is_exe_path +'OurEXE.exe" "parm1" "' + is_request_file + '" "' + is_response_file + '"'

li_rtn = run(ls_command , Minimized!)

li_rtn is coming back as -1. The EXE exists, and if I copy and paste the contents of ls_command into a DOS command box, it executes as expected.

Strangely enough, if I write ls_command into a batch file, everything runs perfectly.

li_file = FileOpen("test.bat", StreamMode!, Write!, LockWrite!, Replace!)
FileWrite(li_file, ls_command)
FileClose(li_file)

li_rtn = run("test.bat", Minimized!)

Does anyone know if Microsoft changed something? Did Appeon change something with the Run() function? Has anyone experienced the same thing? 

Accepted Answer
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 10 January 2023 15:06 PM UTC
  2. PowerBuilder
  3. # Permalink
Hi Miguel; FWIW: Due to other issues when I first migrated to W10 - especially with my framework - I have been using the "Embedded Manifest and "As Invoker" for all my EXE compilations. This setting has worked well for me both running in normal mode and as ADMIN. For the IDE, I always run this "as Admin" since going to W10. HTH Regards ... Chris
Comment
  1. Miguel Leeuwe
  2. Tuesday, 10 January 2023 18:46 PM UTC
Great info Chris!
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Tuesday, 18 February 2020 14:17 PM UTC
  2. PowerBuilder
  3. # 1

If you use the ShellExecuteEx API function and pass "runas" for the action verb, it will run the program as administrator.

Take a look at this code example, it lets you run a program and wait for it to finish. It also captures the return code.

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

 

Comment
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Monday, 17 February 2020 17:18 PM UTC
  2. PowerBuilder
  3. # 2

No, Appeon didn't change anything with how the RUN function works.  Windows keeps changing, especially when it comes to security. 

Try running your compiled PowerBuilder app as administrator or if you are not using a compiled app to test then run the PowerBuilder IDE as administrator.  https://www.windowscentral.com/how-set-apps-always-run-administrator-windows-10

Comment
  1. Miguel Leeuwe
  2. Tuesday, 18 February 2020 03:53 AM UTC
Hi Chris,

I followed that advice some time ago and as a result, users could no longer access the registry using RegistrySet() on LOCAL_MACHINE. When I mark "use highest available" (or something like that), it did work, but I have administrator rights on the PC. So just to be "safe" (sic) I offed the manifest again and had to redistribute new executables to our customers.

The PB help could be a bit more extensive on these settings.

Just warning anyone who might want to use this.

regards,

MiguelL

  1. Helpful
  1. John Raghanti
  2. Tuesday, 18 February 2020 12:51 PM UTC
I did modify the exe to always run as administrator and the Run() function fired off and returned 1 as it always did. Maybe Microsoft manipulated their security environment on us.



We are using the Embedded Manifest with Highest Available execution level.



Would an External Manifest act any differently?
  1. Helpful
  1. Miguel Leeuwe
  2. Tuesday, 18 February 2020 16:43 PM UTC
Hi John, I don´t know, I wish I had more information about the Manifest limitations.
  1. Helpful
There are no comments made yet.
John Raghanti Accepted Answer Pending Moderation
  1. Monday, 17 February 2020 13:50 PM UTC
  2. PowerBuilder
  3. # 3

Hi, all of the paths are correct. When we write the same string to a batch file, it works as expected. I'm not specifying a path for the batch file, and it is being created in the same location as our main application. The "\" is added after is_exe_path.

Comment
  1. Miguel Leeuwe
  2. Tuesday, 18 February 2020 03:57 AM UTC
So the single quote before "ourexe" is a typo?

regards
  1. Helpful
  1. John Raghanti
  2. Tuesday, 18 February 2020 12:47 PM UTC
The content is formed correctly. Everything is encased in single quotes so that double quotes can be used in case there are spaces in any of the pathing. I write ls_command to a batch file and it executes as expected.
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Monday, 17 February 2020 13:16 PM UTC
  2. PowerBuilder
  3. # 4

Are you sure the ' right before the OurEXE.exe is correct? The closing / opening one seems to be missing.

What's in is_exe_path ? Does it end on "\"? Are there spaces in the path?

regards

 

Comment
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Monday, 17 February 2020 13:14 PM UTC
  2. PowerBuilder
  3. # 5

Hi John, No recent changes to my knowledge.

Does your app have app specific App Path defined in Windows registry?
Or did your C# app change "folder"? I wonder if running .EXE directly from PB instead of via .BAT file influences its "start folder"...

TIP: Here's what I do to review exact text passed to RUN function when that function hassles me:

long ll_status
string ls_command
ls_command = ...

// Place on clipboard
ClipBoard(ls_command)

// Execute
ll_status = Run(ls_command)
if ll_status ...

HTH /Michael

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.