I have a Visual Studio setup project.
Upon installation, it creates an uninstall batch file in the application folder. IF the user wants to uninstall the product, he can go to “Add/Remove Programs”, or he can just double-click the uninstall.cmd. The contents are:
%windir%\system32\msiexec /x {CC3EB7BF-DD82-48B9-8EC5-1B0B62B6D285}
The GUID there is the ProductCode from the Setup Project in Visual Studio.

But, in order for upgrades to work properly, I have to increment the Version number, every time I produce a new MSI. And, if I increment the Version number, then I also have to generate a new Guid for the ProductCode. Which means the static uninstall.cmd file needs to change.
How can I dynamically generate a batch file that contains the ProductCode for the, at build time?
This is the script I wrote that creates an uninstall.cmd. It runs as a custom action during installation.
The result is a cmd file that always has the current ProductCode in it.
The downside of this is that ?the script that creates the uninstall.cmd remains in the installation directory. Not a huge problem but I don’t like the rubbish in the install directory. I haven’t yet tried to make the “createInstaller.js” self-deleting. That might work.
EDIT: yes, making the createInstaller.js self-deleting works fine.
I’m going to accept my own answer!