When execution an application for the first time, I want this running applicationto be copied to C:\Program Files\
Say I give this application to my friend then he executes it for the first time and this application must do the copy to C:\Program Files\
How to code it?
You are trying to create a Click Once kind of application. Check the link Click Once Deplyment
You cannot move an EXE file while it is being executed, you will either:
have code that copies the EXE to another location
IO.File.Copy()
or have an installer
Click Once installs to a really obsecure location, not program files. It does NOT require admin.
If you add a MSI setup project to your solution you can see this answer to hardcode the install path to C:\Program Files\
If you choose the MSI solution you will need Admin to install. Because the setup.exe is responsible for the downloading/installing components (such as dotnet) it requires Admin to be executed.
If you know the PC your application is going to be installed on already has the .Net Framework & etc then the easiest way to avoid the UAC prompt is to run the MSI not the setup.exe. Running the MSI wont ask for admin.
You can also follow this answer to make your upgrades install to the same folder.
Related
Now I have a completed program, that needs to be deployed with some files. I would like to ask, if it is possible to deploy the program without the use of ClickOnce or other external tools, with the minimum amount of required files?
The program will run on a server, and will be updated locally, but since the program is installed per user, does that mean if I log in to the server with my user, a person that uses the direct path to the program will not find it? It also makes maintaining the program slightly more annoying, because when changes come, the current maintainer will have to always navigate to the xyz folder to edit one config file. How do I publish the program without ClickOnce or other tools?
Your options include:
Click once (which you don't want)
Visual Studio installer Projects
WiX Toolset
Other installers ...
Write an installer on your own (wouldn't recommend)
Just put the exe (and other needed files) in some directory and launch the program
Put the exe on a shared location and launch from there
You can redistribute as a set of files. However I would not recommend this approach. You force the person who deploys your program :
Choose location for the files
Remember this location when time to uninstall comes.
Handle updates and version management
Restore program functionality if any of the required files will get damaged.
You can use VS Setup project template, here's tutorial
Alternatively you can use free Wix installer, it has a bit of a learning curve but provides much more power to the developer.
You can do perMachine install both with VS setup project and with wix.
I've just tried ClickOnce for the first time to deploy my SQL Server Compact application. I think this kind of deployment is very unprofessional:
The output setup is a folder including 3 objects, one folder named Application Files, a setup.exe and a .application file which I've never seen in a professional product setup package.
Plus, clicking setup.exe seems to help user install the application so quickly but user has no chance to select what location s/he wants to install the application. It's installed by default at somewhere in the target computer. And even I tried looking for its location after the installation, I couldn't find it.
The last, after the installation, there is a folder named "Microsoft" in All programs menu, and the installed application shortcut is located in there. I wonder why it is always Microsoft? I even tried editing my Company info in Assembly info through Project Properties window. The application shortcut is something strange when I can't find its target executable file in its properties window.
With all the above ClickOnce can bring to me, I consider it as a funny job for testing the application only not for publishing a commercial application.
Could you please correct me if there is any wrong in #1, #2, #3 and please give me a better solution for deployment, I'm interested in SQL server (service-based and file-based) application only?
Your help would be highly appreciated. Thanks.
A ClickOnce install is a per user "sandboxed" install, not a normal install you think about when installing normal applications. The .application file is used by the server as a manifest and to determine if it needs to update the install when clicked.
The reason you can't find setup.exe is because it isn't there. Once the files are installed, it isn't kept. The user isn't supposed to know where the files are, the system manages the location and updating of the app.
So, with all that, it appears you need a more normal install, not a ClickOnce. ClickOnce isn't intended to install services or other per machine files.
I have a C# project that I've written using the .NET 4 framework, I've created an installation project using the setup wizard within the solution, the problem is that once the program is installed and I launch it, a dialog appears saying that the program is being configured and then starts the program, why is this? Is it necessary? How can i prevent this from appearing or happening altogether?
UPDATE
I installed my application and launched the application from the .exe created in Program Files and a config window didn't appear and the app launched normally! How do i create a link to this shortcut without it showing the windows shown above? As i need to place a shortcut to the users startup folder.
This happens because Windows Installer detects missing resources. For example, some of the installed files were moved/removed/renamed or were installed per-user for another user account.
Here is an article with more details: http://setupanddeployment.com/general-installation-problems/preparing-install-popping/
You can use Event Viewer to determine which resource is causing this, like explained in the article I mentioned.
The MSI file has auto-repair enabled. I don't think VS has an option to turn it off.
The shortcut links generated don't actually link to the files they should. They link to an executable in appdata. When that file's opened, it runs the installer repair check silently and opens the configuring dialog while any repairs take place. For some reason the installer thinks that files installed with your program are being deleted / corrupted. Perhaps temporary or configuration files?
This link given in this question should fix it if that's the case, but it'll still be activated if the user hits Repair in Add/Remove programs.
I have a working program that I am ready to generate an MSI from for distribution. The default install location is C / Program Files / Foo / Bar , and that's where I'd prefer it install. However, after installing in that location, the program refuses to run unless right-clicked and "run as administrator".
I understand that the program requires administrator access because it is installed in C / Program Files (I have an alternate install path that installs it to the desktop that lacks this problem), so I am looking for a way to not have to run the program as an administrator every single time I want to use it.
I had thought that installing the .msi "as administrator" would solve the problem, but right-clicking the .msi does not provide a "run as administrator" as I expected.
Is there any way to make it so I don't need to run the program as an administrator each time, while maintaining the c / program files install directory?
Build the MSI with a setup.exe. You can then right click the EXE and run as Admin. You can't do this to the MSI because it isn't a program, it's a document ( database ) that's executed by a different program ( msiexec.exe ).
Usually this happens when the application tries to write data in a per-machine location (like Program Files or HKEY_LOCAL_MACHINE). In this case the application will work only if it's launched as an Administrator.
A solution is to use per-user locations for application data. For example Application Data (AppData) folder under the user profile folder and HKEY_CURRENT_USER.
However, if your application really needs Administrator privileges, you can use an UAC application manifest.
VS 2008 SP1
I have created a application that I have installed on the user computer. However, I want the application to be self-updating. But I am not sure if this would really update the application.
The application will download all the files from the web server, and replace the files in the directory where the program as been installed to. The user will restart the application.
I am just want to be sure, because I can't replace the installed files with the updated ones. As the application will be running. So really the application cannot delete/replace itself.
So, I was thinking that I could download into another directory, if the program is installed in this directory 'program files/application/1.0.0' then I could download the files to 'program files/application/1.0.1'.
However, when the program restarts, how can it know that it has to execute from the 1.0.1 directory?
I can't use clickonce or the updater block for this.
Many thanks for any advice,
A good option is to make an independant Updater application.
The updater will download the newest version and kill/replace the old.
I think this is the best option, because you can execute the updater within the main appication (so you can say that it´s self-updating), or directly by the user with a shortcut.
The updater can check if the application is running and ask the user to exit the application or kill it by itself.
Forgive my english...
Good luck
All of that is already done for you if you use ClickOnce deployment (Project properties, Publish).
You can wrap the application with a small loader program which will do a version check. If it's out of date, download the newer binaries and overwrite the old ones. If you want to maintain all version you might end up with:
c:\program files\mycompany\myapp\loader (the newer version will point to the latest directory)
c:\program files\mycompany\myapp\v1.0
c:\program files\mycompany\myapp\v1.1
If it's on a LAN, you might be able afford the bandwidth of just re-downloading the binaries on start up instead.
Use Windows Installer for the installation and updating. If you sign your installation packages the user can update your application without needing any administrator privileges.
I've made a website and an application that demonstrates the functionality of what you want on my website.
Wix Clickthrough might meet your needs: http://wix.sourceforge.net/clickthrough.html
I would look into ClickOnce. It can be configured multiple ways, to check for updates before the application runs, to download from the server each time it's run, or check for updates after the application has started.
I have done ClickOnce Deployment and an independent updating application, they both work well. You obviously will have more flexibility over an updating application that you create yourself, however tho, ClickOnce can also be configured to install prerequisites such as the .NET Framework, Windows Installer, etc... for your application to run.