I'm using VisualStudio 2022. I have to create a setup project for my C# WPF application in .NET Framework 4.8. The thing is, I have to add the installation path as an environment variable while installing the application. Also remove it while uninstalling the application. I found command for add and remove environment variable. It is as below,
setx APPQ_Path "C:\Program Files\AppQ" /M
and
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v APPQ_Path /f
Plan is to keep this commands as batch files and execute it after installation and after uninstalling completed. I got some indications as shown below
Is there any other way to achieve this requirement?
Yes. And, this answer removed my first 3 questions.
Also changed the plan to use environment variable. Now, it is creating a file with path in the %ALLUSERSPROFILE%\CompanyName\AppName
as said in the Mofi's comment.
Here is how I did this.
Environment.SpecialFolder.CommonApplicationData
)
Note: We can use other override methods like 'OnAfterInstall' also.