Modify the published project installation directory in Windows8.1


I am trying to change the default installation directory of my projects when I publish them but I seem to have no choice over where the published setup.exe actually puts the program. It seems after setup.exe running and application installed, all the processed files are under the folder of C:\Users\{username}\AppData\Local\Apps\2.0\ (Something like that, I dont remember the exact directory as it is very long). This is not what i want as I installed the program in the C:\Program Files\ but all the log files go to the C:\Users\{username}\AppData\Local\Apps\2.0\. This is really really annoying.

The application I published is C# Windows Form Application

And I have looked through online and found that somebody suggested to create an MSI package for C# Windows Application Using a Visual Studio Setup Project instead of publishing the program:

Publish Windows form application how change the installation path

It is supposed that the above website can solve this problem. Are there any other suggestions to solve this redirection problem after publishing the C# Windows Form Application? Thank you.

When you use the Publish funtion in Visual Studio, you are creating click-once publication. This type of deployment has relatively fixed rules and not everything can be configured. It allways installs into an obfuscated folder under windows user profile. It is similar to the fact, that you cannot change location where windows-store modern apps are installed under Windows 8.1.

You can create MSI setup project for your app - but in Visual Studio 2012 this type of project is missing and it was re-introduced againg in Visuals Studio 2013. There you can specify install folder. You can also use Install Shield Lite with Visual Studio 2012.

You wrote:

This is not what i want as I installed the program in the C:\Program Files\

It is not possible to install ClickOnce application using Publish button in Visual Studio into C:\Program Files\.

If you have just problem with the location of your log files, you need to specify a different folder within your application code. Make sure that user, who is running your app, has write access to that folder - it should be in some user's profile folder or in a public folder. Avoid %ProgramFiles% as a folder for your log files - it is not a good practice.

Instead of Application.StartupPath you should use path accessible to all users including non-admin, like: