问题
In the process of upgrading from PostgreSQL 11 to 12 on Windows, I uninstall PG-11 using the uninstall.exe, wait for like 15 seconds (to make sure that the uninstall.exe is complete), delete the bindir (if exists) and then install the Postgres-12.exe. This all is done in a batch file and the code looks something like:
uninstall-postgresql.exe --mode unattended
PING 1.1.1.1 -n 15 >NUL
if exist C:\PostgreSQL\bindir RD /Q /S C:\PostgreSQL\bindir
postgresql-12.1.exe --servicename Postgres --prefix C:\PostgreSQL\bindir --datadir C:\PostgreSQL\datadir
On some systems, the uninstall-postgresql.exe completes in less than 15 seconds and the upgrade works.. however on some slow systems, it takes more than 15 seconds due to which the Postgres-12 installations will fail for some or the other reasons.
I want to remove the 15 seconds delay and make sure that the control is given back to the next command in the batch file only when the uninstall-postgresql.exe is 100% complete. Right now, when I run the batch file, it calls the uninstall-postgresql.exe --mode unattended
but the control comes back to the batch file and the next command (in the batch file) is executed while the uninstall-postgresql.exe is running in the background. Is there a way to make sure that uninstall-postgresql.exe completes and only then the next command in the batch file is executed?
Please recommend if there is any way to do so. Thanks in advance.
来源:https://stackoverflow.com/questions/64161815/postgresql-uninstall-on-windows