1. Sivaprakash BKR
  2. PowerBuilder
  3. Saturday, 9 December 2023 12:39 PM UTC

Hello,

Using PB 2022 R2 Build 2819 (64 bit) + TopWizProgramming RunAndWait

I'm trying to install two drivers (depending on choice, PostgreSQL or SQLite) through my application, if not available.  I check for driver availability and call runandwait, if a particular driver is not found, through the command.

For PostgreSQL Driver

/* To silently install the driver */
ls_exe = "E:\Postgresql\driver\psqlodbc-setup.exe"
ls_exe = '"' + ls_exe + '"' + ' /quiet'
If Not lo_run.runandwait(ls_exe, 3) Then
        ls_errormsg = lo_run.LastErrorText
	MessageBox('Error', ls_errormsg, StopSign!)
	ll_ret = -1
Else 
	ll_ret = 1
End If

 

For SQLite Driver

/* To silently install SQLite Driver */
ls_exe = "E:\SQLite\driver\sqliteodbc_w64.exe"
ls_exe = '"' + ls_exe + '"' + ' /S'
If Not lo_run.runandwait(ls_exe, 3) Then
	ls_errormsg = lo_run.LastErrorText
	MessageBox('Error', ls_errormsg, StopSign!)
	ll_ret = -1
Else 
	ll_ret = 1
End If

 

PostgreSQL asks a confirmation message and installs.  No issues.

I get the following message while installing SQLite.
The requested operation requires elevation.

Is there is any way that a program could be executed in elevated mode, through RunAndWait?

Happiness Always
BKR Sivaprakash

 

Chris Tillman Accepted Answer Pending Moderation
  1. Thursday, 4 April 2024 07:30 AM UTC
  2. PowerBuilder
  3. # 1

Hi Roland,

Just wanted to say thank you so much for your RunAndWait contribution. It's really nice code, and you probably prevented more than one suicide from getting -1 on the Run command. :)

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Sunday, 10 December 2023 02:09 AM UTC
  2. PowerBuilder
  3. # 2

Use 'runas' for the shellverb argument of the ShellRunAndWait function.

iRun.ShellRunAndWait("myprogram.exe", "runas", iRun.SW_SHOWNORMAL)

 

Comment
  1. Roland Smith
  2. Monday, 11 December 2023 02:49 AM UTC
The structure passed to ShellExecuteEx has a property lpParameters which can be used for that. Add a new argument to the function so you can pass the arguments.
  1. Helpful
  1. Sivaprakash BKR
  2. Monday, 11 December 2023 05:34 AM UTC
Thanks Roland, It works.



I get a confirmation message from windows.

Do you want to allow this app from an unknown publisher to make changes to your device?

When executed from ShellRunAndWait.



The same message doesn't appear when I open the IDE or Exe as an administrator.



Just to know whether any other option is available in ShellRunAndWait without displaying this message?

  1. Helpful
  1. Roland Smith
  2. Monday, 11 December 2023 19:55 PM UTC
Not that I know of. Being able to easily suppress the message would defeat its purpose. I would have the main app run as admin. There is a function you can use to determine if you are running as admin. I have a program that exits if not admin.



Function boolean IsUserAnAdmin ( ) Library "shell32.dll"

  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.
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.