how to debug a batch file that does not return

davecramer's Avatar


06 Nov, 2017 09:09 PM

How do I debug something that is not responding.
I have a batch file that does not return ..

  1. Support Staff 1 Posted by Ilya Finkelshte... on 06 Nov, 2017 09:55 PM

    Ilya Finkelshteyn's Avatar

    You can add some messages to write to console (like echo step1) after each step to see how far it went. Also you can connect to build VM with RDP and run script line-by-line manually. Note however that build-specific environment variables are not available in RDP session so you need to define and add values to variables your script use, or use absolute values for debugging.

  2. 2 Posted by davecramer on 08 Nov, 2017 06:29 PM

    davecramer's Avatar


    I am trying to start postgres using pg_ctl in a test_script

    bin\pg_ctl -D data -l logfile start
    waiting for server to start.... done
    server started

    It does not return after this.

    Any ideas what is up ?

    Dave Cramer

  3. Support Staff 3 Posted by Ilya Finkelshte... on 08 Nov, 2017 09:01 PM

    Ilya Finkelshteyn's Avatar

    Probably server starts interactively and blocks build execution. You can avoid starting script with Start-Process PowerShell command. But do you really need to start PostgreSql from custom script? You can use built-in AppVeyor setting.

  4. 4 Posted by davecramer on 08 Nov, 2017 09:39 PM

    davecramer's Avatar


    The server is not waiting for input. It starts on it's own without it.

    Well you don't have pg10 for one.
    Secondly I need R_HOME set and the path modified before postgres starts.

    I'm open to suggestions though

    Dave Cramer

  5. Support Staff 5 Posted by Ilya Finkelshte... on 08 Nov, 2017 09:54 PM

    Ilya Finkelshteyn's Avatar
    • Filed this issue to add PostgreSQL 10

    • I did not try this command myself, but it is still worth trying to wrap it in cmd and call from Start-process as in this sample. It is common approach for many similar cases. Also note TCP port probe to ensure server is really listening.

    • You do not have to update path in the same script. In can be separate command in the script block

  6. 6 Posted by davecramer on 08 Nov, 2017 09:56 PM

    davecramer's Avatar

    I need the path to be set before the service starts and the service has to
    inherit that environment.

    Thanks I'll try cmd

    Dave Cramer

  7. Support Staff 7 Posted by Ilya Finkelshte... on 08 Nov, 2017 09:58 PM

    Ilya Finkelshteyn's Avatar

    All commands are in the same user context, you can safely set path at install stage for example and it will be visible to the other build steps.

  8. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:21 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac