1. MARK APTEKAR
  2. PowerBuilder
  3. Sunday, 19 March 2023 16:30 PM UTC

Hi, I am using PowerBuilder 2019 R3 build 2703.

Created service for ‘srvany.exe’ on Windows Server 2016.

Program (let’s call it BAR) starts when runs as a service. Window ‘password’ opens from the application object Open event ‘Open(w_pass)’

User id and password sets from INI file in the ‘w_pass’ open event, then calling cb_ok.PostEvent(clicked!)

Database connection established in the cb_ok clicked event then calling Open(w_main)

Window ‘w_main’ not opens if program runs as a service, but if I run that same program on desktop it is working without a problem.

There is another PowerBuilder program (very similar to the BAR, let’s call it ADT) runs on the same machine.

The ADT program is running as service without any problem. Both programs have similar codes how to sign-in and open main window but BAR not working.

Is anyone come across similar issue? Does anyone know what and where I need to check to find the problem?

 Thank you, an advance, for your time and help.

MARK APTEKAR Accepted Answer Pending Moderation
  1. Monday, 3 April 2023 16:42 PM UTC
  2. PowerBuilder
  3. # 1

The main problem was - insufficient memory on the machine where all those programs are running as services. There are no more issues after memory upgrade.

Comment
There are no comments made yet.
MARK APTEKAR Accepted Answer Pending Moderation
  1. Tuesday, 21 March 2023 15:51 PM UTC
  2. PowerBuilder
  3. # 2

Thank you very much Roland! Programs start working as services after I checked service option 'Allow service to interact with desktop'.  I did not see any message box pops up, but it does not matter as far as its working! 

Thank you ALL who replied to my questions and tried to help me!

Comment
There are no comments made yet.
MARK APTEKAR Accepted Answer Pending Moderation
  1. Tuesday, 21 March 2023 14:07 PM UTC
  2. PowerBuilder
  3. # 3

Thank you John for the detailed explanations. but with the greatest respect,....that is not true. Simply because there are dozen of other PowerBuilder programs running on the same machine as service for many years. Some programs created in PowerBuilder 9, some in PB 12.5 some in PB 2019. Most of the objects in those programs are visual objects and all of them never had issues when running as service using 'srvany'....except two programs now. Both programs that are having issue created in PowerBuilder 2019 R3 2703 (to be more specific, migrated), but I cannot 'blame' that version of PowerBuilder for it because there is also program created using same version of PowerBuilder (migrated) and running as service without problem.

 

Comment
  1. Chris Pollach @Appeon
  2. Wednesday, 22 March 2023 18:31 PM UTC
Hi Roland / John;

While that option would make it work .. it does not make sense for an *unattended* server. Where no operator would ever see any dialogues. - especially on auto reboot . At the previous customers that I used to consult for, their production teams would *never* allow that option.

Also, newer MS-Windows O/S releases, newer Anti-virus, or "Policy" changes could easily stop that from working. Just my $0.02

Food for thought.

Regards ... Chris
  1. Helpful 1
  1. Olan Knight
  2. Thursday, 23 March 2023 04:29 AM UTC
I agree. A SERVICE should be unattended and require no user interaction. While I can see (barely) using a LOGON window for a Service, if there is >>> ANY <<< other user interaction the EXE should not be a service. Remember that standard apps can run in the background for a LOOOOOOONG time.
  1. Helpful
  1. Mark Goldsmith
  2. Friday, 24 March 2023 22:04 PM UTC
Hi Mark...you may be able to still see any messages that pop up via changing some settings:

1) Under Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows change the key NoInteractiveServices value from 1 to 0

2) Open the Interactive Services Detection service and change the Startup setting to Automatic

To Chris's point however, Microsoft started to remove the ability to change these settings on subsequent OSs (more so step 2 above as the service is not even available to change any properties) due to security risks from hackers. After certain Builds for Windows 10 this capability has been removed entirely and may be the case for future Server 16 Builds even though it's EOL is presently 2027. This is the case with Windows 11 and Server 19/ 22, any Build, for which these workarounds do not work at all. I haven't tried it but my understanding is on newer OSs or newer Builds of older OSs, not only won't you be able to see the messages via this workaround but the service will go back to what you were experiencing before which is the Open event of w_main will not execute.

Just an FYI in the event you're planning to upgrade the OS on the machine for which you need this service to be available.

@John...as for learning new tricks, this is an old trick that is not aging well on newer OSs lol...and probably for good reason.



HTH...regards,

Mark
  1. Helpful
There are no comments made yet.
MARK APTEKAR Accepted Answer Pending Moderation
  1. Monday, 20 March 2023 21:27 PM UTC
  2. PowerBuilder
  3. # 4

Hi, thank you for the response. Yes, this is correct, LOGIN window is part of the PowerBuilder application. And Yes, I know PB apps that runs as a service can NOT contain visible objects. And I do not need any PB objects to be visible. Login window get user/password info from INI file and connects to the database automatically without any issues. (see log file below line 15:55:48 890 Connected to DB. SQLCA.SQLCode=0 ) App does not failing because it cannot find sign in credentials. App fails because it cannot trigger open event for w_main. (see line 15:55:49 158 w_main open start) but there is no such entry in the log file when app runs as service . last line is 15:58:02 427 Open(w_main). I cannot figure out why open event not triggered. 

log created when app runs on desktop 

15:55:48 304 Open(w_pass)
15:55:48 350 w_password: start
15:55:48 367 gc_auto_start = Y
15:55:48 369 cb_ok.PostEvent(clicked!)
15:55:48 370 w_password: end
15:55:48 388 cb_ok - start
15:55:48 391 Connect;
15:55:48 890 Connected to DB. SQLCA.SQLCode=0
15:55:49 034 Open(w_main)
15:55:49 158 w_main open start       >>>>>  open event triggered
15:55:49 239 w_main open end
15:55:49 264 Close(Parent) w_password
15:55:49 268 w_password closed
15:55:49 269 w_main postopen start
15:55:49 270 Open(w_count)
15:55:56 086 wf_flex(0)
15:55:56 189 w_main postopen end
15:55:56 190 w_pass opened
15:56:00 448 Close interface

log created when app runs as service

15:58:01 769 Open(w_pass)
15:58:01 793 w_password: start
15:58:01 811 gc_auto_start = Y
15:58:01 812 cb_ok.PostEvent(clicked!)
15:58:01 813 w_password: end
15:58:01 838 w_pass opened
15:58:01 839 cb_ok - start
15:58:01 846 Connect;
15:58:02 302 Connected to DB. SQLCA.SQLCode=0
15:58:02 427 Open(w_main)    >>>  open event NOT triggered. Nothing happens after that line.

 

 

 

Comment
  1. John Fauss
  2. Tuesday, 21 March 2023 00:43 AM UTC
Mark, you simply cannot USE (that includes instantiating) ANY visual objects in an application that will execute as a service. Not executing code, such as in a window's Open event, is not sufficient and will NOT work and there is nothing you can do to change that. All of the code your "service" app will be executing has to be contained within non-visual objects (NVO's). This is what Chris mentioned earlier. Your best approach would be to create a new application that uses only NVO's instead of trying to leverage existing code contained within visual objects. See my comment in the post immediately below for more explanation on why this restriction exists. Good luck!
  1. Helpful
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Monday, 20 March 2023 19:16 PM UTC
  2. PowerBuilder
  3. # 5

It appears to me as if your LOGIN window is part of the PowerBuilder application. Since PB apps run as a service can NOT contain visible objects, I'd guess that's why the app it is failing when run as a service.

Option:  Create a separate PowerBuilder LOGIN app for your service apps. This app will write your credentials to a file that your service app will read, then delete.

Comment
  1. Chris Pollach @Appeon
  2. Monday, 20 March 2023 20:07 PM UTC
Right on Olan! ;-)
  1. Helpful
  1. John Fauss
  2. Monday, 20 March 2023 21:01 PM UTC
Totally on point, Olan.

The Windows OS manages GUI threads much differently than it does non-GUI threads, as there are more types of resources that need to be tracked and managed. The additional complexity of setting up a DefWindowProc (default Windows message handling procedure) to handle user interaction may also be a factor. This is why an application that runs as a service should ONLY be coded with non-visual objects (NVO's, as Chris clearly stated in his initial and second response to this issue. As soon as you include a visual object in a PB app, it becomes a GUI application and it will execute in a GUI execution thread.
  1. Helpful 1
  1. Olan Knight
  2. Monday, 20 March 2023 21:19 PM UTC
Great info, John! Thank you!

I learn something new every day! :)
  1. Helpful
There are no comments made yet.
MARK APTEKAR Accepted Answer Pending Moderation
  1. Monday, 20 March 2023 14:22 PM UTC
  2. PowerBuilder
  3. # 6

Thank you for the reply. I know that login info is available, and program connected to the database. Below is info from the log files when program runs on desktop # 1 and as servise # 2. Line "09:02:08 883 Open(w_main)" written into the file right before calling Open(w_main) from the w_pass (without DB connection logic will not get to this point). Next line "09:02:09 017 w_main open start" is a first line in the w_main open event.  Log file for # 2 (runs as service) never has any info after line "09:05:18 983 Open(w_main)", Open event for w_main never triggered when program runs as service. This is what I am trying to figure out - why it 'hangs' and cannot open w_main.

 

1) info when running on desktop: 

09:02:08 262 Open interface
09:02:08 286 w_password: start
09:02:08 303 gc_auto_start = Y
09:02:08 304 cb_ok.PostEvent(clicked!)
09:02:08 305 w_password: end
09:02:08 325 w_pass opened
09:02:08 326 cb_ok - start
09:02:08 328 Connect ;
09:02:08 883 Open(w_main)
09:02:09 017 w_main open start
09:02:09 107 w_main open end
09:02:09 148 Close(Parent) w_password
09:02:09 155 w_password closed
09:02:09 157 w_main postopen start

2) info when running as service:

09:05:18 362 Open interface
09:05:18 386 w_password: start
09:05:18 403 gc_auto_start = Y
09:05:18 404 cb_ok.PostEvent(clicked!)
09:05:18 405 w_password: end
09:05:18 425 w_pass opened
09:05:18 426 cb_ok - start
09:05:18 428 Connect ;
09:05:18 983 Open(w_main)

 

Comment
There are no comments made yet.
Brad Mettee Accepted Answer Pending Moderation
  1. Monday, 20 March 2023 13:51 PM UTC
  2. PowerBuilder
  3. # 7

Best guess is that the info you're using to login is not available (whether it's a registry setting or an ini file). As Chris said, if you log your vars, you'll be able to see what it's trying to use as login info.

Comment
There are no comments made yet.
MARK APTEKAR Accepted Answer Pending Moderation
  1. Sunday, 19 March 2023 17:06 PM UTC
  2. PowerBuilder
  3. # 8

Hi, Chris. Thank you for the quick response.

Yes, sure I know program is not 'visible' when it runs as service. I added some kind of debugging into the code that is writing into the file some break points info as:  w_pass - open,  cb_ok - clicked,  cb_ok - DB connected, w_main - open, w_main close, ....ext.   This is how I know that 'w_main' never opens when program runs as service. Because there is no entry in the log file "w_main - open" that should be logged when open event for 'w_main' triggered.

Comment
  1. Chris Pollach @Appeon
  2. Sunday, 19 March 2023 17:47 PM UTC
These type of Apps need to be all implemented via NVUO's. ;-)

Logging is your best debugging avenue.

However, you can also use something like this as remote console ...

http://chrispollach.blogspot.com/2019/12/socket.html
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Sunday, 19 March 2023 16:50 PM UTC
  2. PowerBuilder
  3. # 9

Hi Mark;

   FWIW: "Service" programs are not to have any visual interface!

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.