Jump to content

LabVIEW with PostgreSQL psql.exe password request

Recommended Posts

I am trying to connect a PostgreSQL database (ver 9.6) with LabVIEW (2016) on Windows 10.

I followed the following tutorial:


Without access to a cRIO, I have followed the steps to create the database, table and block diagram. Please see block diagram attached.The system exec.vi calls the psql.exe with SELECT command using database "lisam" and database user "postgres".

When I execute the same code I am asked for the password for user postgres. When I type in the password, the box closes and reopens. This continues in a loop until I press abort. I get no errors and when I write the same script into the cmd - the password is accepted and the table is displayed, see attachment.


  • Password request from the psql.exe file when executing LabVIEW code
  • Type password, psql.exe closes and opens again
  • SELECT query works without while loop (password accepted once) but insert and clear does not without the loop condition

What I've tried...

  1. Created a pgpass.conf file in a postgresql folder in %AppData% in the following format:- hostname:port:database:username:password, where lisam is the database, postgres is the user.

Host name as localhost '' - password still requested.

Host name as 'localhost' - psql.exe flashes continously and LabVIEW crashes. localhost:5432:database:username:password

Host name as database client address '::1' - password loop with the psql.exe.


Host name to '*' -


Able to:

  • Access the database through the cmd WITHOUT password

    C:/Program Files/PostgreSQL/9.6/bin/psql -c "SELECT * FROM demo1" lisam postgres


  • Execution in Labview - psql.exe flashes continuously and the program crashes.
  • Accessing database through psql.exe directly - password requested and ERROR received
    "psql: FATAL: password authentication failed for user C:\Program Files"

2.Changed the authentication method in pg_hba.conf to trust for:

  • localhost ( a password is still requested.
  • AND ::1 - Can access the database on psql without a password, but the psql.exe LabVIEW completely crashes.

    1. I tried adding the host and port to the code

      C:/Program Files/PostgreSQL/9.6/bin/psql -c "%s" -h -p 5432 lisam postgres

And the psql.exe flashes continously and won't abort.

  1. The password is called at the system exec VI in the cmd. Tried concatenating the password (as a control) with space constant to the command line string inbetween the format into string and the system exec VI. But the password is given before it is called.

In summary I am able to use .pgpass.conf to authenticate the password when using the cmd, but not in LabVIEW. Does anyone know a way around this? Or another way to define the password at the system exec VI?

Your help is greatly needed.



  • database name: lisam
  • database user: postgres

IPv4 local connections-

    host all all md5

IPv6 local connections-

    host all all ::1/128 md5

    DB:lisam Client Address ::1
    psql Client address




PostgreSQL with LabVIEW.png


Edited by lisam
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Similar Content

    • By smidsy
      I would like to implement a Run-time license checking mechanism that will enable or disable some parts of my LabVIEW API depending on a license status. 
      After reading numerous discussions here on the forum (We need a new password cracker :( , Low level VI data editor (warning: not for production use!) , I found some more hidden INI keys, Password Security in LabVIEW) I realised few things:
      - reverse engineering in a LabVIEW-related field seems to be a doable task for some smart people, 
      - password protection on block diagrams does not protect your IP, it is more of a "read-only" or a "private property" sign,
      - removing block diagrams or compiling it into an executable are the ways to go, and finally,
      - there are few tools out there, that seem to have a potential to "unflatten" VI data and modify/extract its data even without block diagrams.
      Back to my task. I decided to remove block diagrams. Inside my protected VI I call an external library that does the actual license checking. So the code only gets this status and returns it back to other VIs. Then the VIs do not perform their main functions, and the user gets an error. 
      Do you think I am safe here?
      Is it possible to extract sensitive string information out of my VIs (without BD)?
      Is there a way to change wiring rules/connector pane on my VIs?
      Should I worry about DLL hijacking? 
      Does NI have some kind of a tutorial for protecting your run-time API? 
      How do you protect your API knowing all that? Do you sleep well?
    • By longzoo
      NOTE: while typing this up i found my solution but decided to post anyway in case it may help someone else
      I decided to quit beating my head off the keyboard and ask for help...I have a vi that will eventually be an .exe distributed across a variety of windows xp to windows 7 machines (32 and 64 bit). In this vi a bunch of data is saved to a .tsv file at C: i then need  to open the .tsv file in excel. After some searching i found System Exec.vi. it initially seemed to be my silver bullet because if i open command line in windows and type " excel.exe c:temp.tsv" Excel is opened (and this should work across different versions of Office). BUT with system exec.vi i get an error "Error 2 occurred at System Exec.vi Command was "excel.exe c:temp.tsv" Possible reason(s): LabVIEW: Memory is full." blah blah blah...
      If i replace "excel.exe" with Notepad it opens the data no problem with notepad but i need it to be in Excel. i read about using "cmd /c" and attempted to no avail
      Here's where i found my issue... it is "cmd /c" NOT "cmd c" ! so i used "cmd /c c:temp.tsv" and voila it opens with the default program for .tsv (which is obscure enough that i can make Excel a default on all of the computers in the building) for some reason cmd /c excel.exe does not work to open excel. i found this odd as excel.exe entered directly in the command line will open excel regardless of which version you have installed, but i believe i can live with this. 
    • By Ton Plomp
      On Stackoverflow someone posted a question on how to recover a VI's password
      To my surprise there was a thorough answer containing two methods:
      Look up the stored MD5 hash in a VI file
      I can understand this, and am not really concerned, this might be a valid method if you know a password is from a given list (choosing a password from a dictionary is dumb anyway).
      Modify the LabVIEW executable binary to ignore the password checking.
      I have not tried this on LabVIEW 2011, but if this works it basically means that passwords are just a sign that says 'Do not trespass'

      Can anyone verify the LabVIEW edit function in 2011.
      On a more general discussion, does this troubles you anyway?
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.