A clickonce deployed application is installed only for the specific user? - windows-7

Are there any defaults in the clickonce installation?
If someone decides to install the application, this application will be availiable to all the users of the computer?
I guess the answer is no. They can only use the application if they log into the user account who installed it... but sometimes it is better to ask

No, according to this matrix in the Microsoft article "Choosing Between ClickOnce and Windows Installer"
"Install for All Users" is not supported. As said in the article (emphasis mine):
Now that I've taken a quick look at features of both Windows Installer and ClickOnce, you will note that each technology was quite different goals.

ClickOnce applications are deployed into a folder nested deep within the user's profile folder (under C:\Users on Vista/7 - you can find it in the %USERPROFILE% environment variable), so they're only accessible by the user who installs them.
There's nothing stopping each user on the PC from installing their own copy of the application, though, and ClickOnce apps generally have a small footprint, so this is a valid option.

See this page at microsoft.com, it has a table with differences between windows installer and Clickonce:
http://msdn.microsoft.com/en-us/library/ms973805.aspx

Related

Does installing my app into Local Application Data folder has drawbacks?

Currently planning on making the installation process for a .NET application I'm selling smoother (read: "possible") for non-administrator users, I stumbled upon applications like Google Chrome and Microsoft SkyDrive:
They seem to not install into the usual "Program Files" folder, but instead into the "Local Application Data" folder of the current user.
Since this folder is on a per-user-basis, it is writable for the current user and no administrative permissions are required to write into.
I've managed to change my NSIS setup to work correctly and install into this folder, but I'm still unsure whether this is good practice and might have drawbacks or not.
My question is:
Do you have any recommendations on why to install or not to install into the "Local Application Data" folder?
(I do hope this question is programming-related enough to be kept here)
It was not clear from your question but you should install the program in $LocalAppdata\Programs and not just $LocalAppData (FOLDERID_UserProgramFiles constant in Win7)
I know I like apps that can install as non-admin, at least you know the app does not require a driver or that it messes with the machine configuration in other ways.
Some people prefer to do a machine-wide install and giving the user this option is not that hard in NSIS:
RequestExecutionLevel highest
Add a custom page with two radio buttons (Just Me and All Users) and gray out the machine-wide choice if user is not admin (UserInfo plugin)
Set $Instdir and SetShellVarContext based on install mode
Use SHCTX as the registry HKEY
Some IT people/domain admins might not be happy if their users can install stuff, that is the only negative I can think of but they should lock down the system properly if they think it is a problem IMHO...

How do I make my program work in Windows Vista and Windows 7?

I have an application written in Delphi 2006 that was working fine in Windows XP. I packed the application using Inno Setup, using Program Files as the default folder. A few users migrated to Windows Vista and Windows 7. The issue here is that the application creates some files inside its installation folder by its own. This was working in XP but in Windows Vista the users were having problems with the created files (they don't appear and so on). After investigating the users' reports I discovered KB 927387: "Common file and registry virtualization issues in Windows Vista or in Windows 7."
Running the application with administrator rights just solves the problem, but that is (I think) an awful workaround. I would like to know if there are any directives or tips for making the application compatible with Vista and 7, because more users will migrate to these OS soon.
You need to re-write your application to store its files in the proper locations, even in XP, but especially in Vista onwards, particularly if UAC is enabled. This is becoming more and more important to get right as Microsoft keeps locking down and enforcing its security models with each new OS version. The rules for how to properly manage application- and user-related files is documented on MSDN, for example: "Application Specification for Microsoft Windows 2000 for Desktop Applications, Chapter 4: Data and Settings Management" and "Application Specification for Microsoft Windows 2000 for Desktop Applications Appendix A: Best Practices" (yes, they are old, but are still quite relevant). Look at SHGetSpecialFolderLocation(), SHGetFolderPath(), SHGetKnownFolderPath() and other related functions to help you.
For Vista/Win7, your app can't put the files in a subfolder of Program Files / Programs unless UAC is turned off or the app is running as elevated. Note that "elevated" does not necessarily mean "logged in as Administrator." Non-administrator users can elevate, and Administrator isn't necessarily elevated.
If the app does attempt to write to Program Files but is not elevated, the OS will either block the app or "virtualize" the write (put the files somewhere else), depending upon how UAC is configured. Neither one helps the app succeed at what it was trying to od.
So it needs to put them somewhere else. Where depends on why the files are being created, and you haven't told us that. You can read this article to learn about the options. Note that in addition to the user's AppData and Roaming folders, there is also an "All Users" (shared) profile.
You should probably look at this article and screencast, which discusses UAC in depth from a Delphi point of view.
Files you create for use by your application other than at installation time should go into the ProgramData directory if its global to the workstation, or into the users ApplicationData directory if its specific to the user.
For cases where you absolutely must place a file in the program files directory, you can use com to request elevation. This is discussed in great detail, and delphi specific bits are also available. One example that I have used this is in patching my users installation base. They are warned by UAC that the system needs to make changes, so if your doing this as an automated task, you might need to rethink the logic to be more user driven.
Here is another article, by Zarko Gajic, which shows how to get different system directories. Also have a look at this related question.
I had a similar enquiry here (Stack Overflow).
In the end I realised that I needed to put my application into Program Files at install time (requiring UAC/elevation) and then store my app's data in the user's App Data folder. I had to change the way my program generated 'default' configuration settings and also where I was saving this stuff, but it was worth the effort in the end - we ended up with something that installs and runs fine on XP, Vista and Windows 7.
The only UAC hit we get is at installation time, which makes sense to me (and you get a similar hit at install-time on the Mac too). We didn't have any data that would be common to all users in this particular case but I would have looked at the Program Data special folder if that had been the case.
The installer software we use (Setup Factory) made this fairly straightforward (we just wrote a small bit of code to detect XP versus Vista/Win7 and choose the right special folder accordingly). It would be easy to do this in Inno Setup too, from what limited experience I have of it.

What directory should my installer install an app on Vista?

I've nearly completed developing a game for Windows and I'm curious where I should have the installer install it. I know it used to be in "Program Files" but has that changed under Vista?
I know that World of Warcraft now installs under Users/Public/Games... what is the Microsoft-recommended location for games?
In Vista, the recommended directory is still %PROGRAMFILES%.
Note that in Windows 7, Microsoft has enabled the creation of true per-user installations, including support for per-user Program Files. This is a feature of Windows Installer 5.0, and you can read more about it here:
http://msdn.microsoft.com/en-us/library/dd408068(VS.85).aspx
You should use the Environment variables.
Namely %PROGRAMFILES% for you.
Just read the question a little more thoroughly. From my experience of Vista, most of the gubbins still install to %PROGRAMFILES%. Perhaps the /users/public... path is somewhere where things can install (and update) without having to get admin perms all the time. (A complete guess)
Looks like you should use SHGetKnownFolderPath to ask for the location of the FOLDERID_Games KNOWNFOLDERID.
EDIT: Nope, doesn't look like that is right. This thread has a discussion of FOLDERID_Games and notes that it is a virtual directory. This knowledgebase article discusses the Windows Vista Games Explorer. And this article has some more Vista specific information.
Sorry - this has turned into a non-answer but maybe the links will help you find the answer.
The recommended directory is still Program Files, as everyone has said. However, if you want a per-user install, you could install it in the AppData folder. I know Google Chrome does this to allow installation without being an administrator, and also for user-specific installation.

What are the advantages of installing programs in AppData like Google Chrome?

I just noticed that Chromium was installed in AppData in both Vista and XP. If Google does that and if other applications does this, than is that becuase there is some form of protection? Should we write installers that does the same thing as Google?
Windows still lacks a convention for per-user installation.
When an installer asks whether to install for the current user or all users, it really only refers to shortcut placement (Start Menu; Desktop). The actual application files still go in the system-wide %PROGRAMFILES%.
Microsoft's own ClickOnce works around this by creating a completely non-standard %USERPROFILE%\Local Settings\Apps (%USERPROFILE%\AppData\Roaming on Vista / Server 2008) directory, with both program files and configuration data in there.
(I'm at a loss why Microsoft couldn't add a per-user Program Files directory in Vista. For example, in OS X, you can create a ~/Applications, and the Finder will give it an appropriate icon. Apps like CrossOver and Adobe AIR automatically use that, defaulting to per-user apps. Thus, no permissions issues.)
What you probably should do: if the user is not an admin, install in the user directory; if they do, give them both options.
One advantage nobody mentioned are silent auto-updates. Chrome has an updater process that runs all the time and immediately updates your chrome installation.
I think their use-case is non-standard. They need a way to fix vulnerability issues (since it's a browser) as soon as possible. Waiting for admins approving every single update company-wide, is simply not good enough.
As far as I can tell, the only reason why Chrome installs into the Application Data folder is so that non-admin users can install it.
The Chrome installer currently does not allow the user to pick where the application is to be installed. Don't do that – instead, give the user a choice between a per-user (somewhere like App Data) and computer-wide (Program Files) installation.
Windows 7 and Windows Installer 5.0 provide real per-user installation capabilities now.
http://msdn.microsoft.com/en-us/library/dd408068%28VS.85%29.aspx
You can sort of fudge it in Vista and XP by using ~/AppData/Local or the equivalent like Chrome does. Microsoft themselves use this for the ClickOnce installers.
So at least on Windows 7 and beyond the solution is simple.
Frankly, I have yet to see the first installer that really allows both per-user and per-machine installations. Many installers offer this option in their GUI, but the setting only affects where the shortcuts etc. go -- the binaries always fo to %ProgramFiles%.
In fact, it is pretty hard to create Windows Installer packages that allow both kinds of installs, to say the least. With the advent of UAC, I'd say its is impossible: Per user installations must not require elevation, per machine installations have to. But whether an MSI package requires elevation is controlled via a bit in the summary information stream -- there is no way to have user input have impact on that.
Whether per-user or per-machine is the better choice greatly deoends on the application. For small packages, however, I tend to prefer per-user installations. Besides being slightly more user-friendly by not requiring an UAC prompt or runas, they also signalize the user that the setup will not do much harm to the computer (assuming he is a non-admin).
The Chrome installer really ought to allow global installation (with elevation) in addition to per-user. I don't want to have to maintain an installation for every user; I want to be able to centrally manage upgrades and so on. Chrome doesn't allow that.
That said, the option to install per-user is quite nice, as it means no permissions issues.
Just so you people know, Google has created an MSI installer for global system installation and management. It's located here:
https://www.google.com/intl/en/chrome/business/browser/
I do not see anything in %PROGRAMFILES% on Win7. Looks like Chrome must be installed for each user on the machine.
Perhaps the true reason of doing this is faking number of Chrome installations by few times ! Thus making it first browser in the world !

How do we create an installer than doesn't require administrator permissions?

When creating a setup/MSI with Visual Studio is it possible to make a setup for a simple application that doesn't require administrator permissions to install? If its not possible under Windows XP is it possible under Vista?
For example a simple image manipulation application that allows you to paste photos on top of backgrounds. I believe installing to the Program Files folder requires administrator permissions? Can we install in the \AppData folder instead?
The objective is to create an application which will install for users who are not members of the administrators group on the local machine and will not show the UAC prompt on Vista.
I believe a limitation this method would be that if it installs under the app data folder for the current user other users couldn't run it.
Update:
Can you package a click once install in a normal setup.exe type installer? You may ask why we want this - the reason is we have an installer that does a prereq check and installs anything required (such as .NET) and we then downloads and executes the MSI. We would like to display a normal installer start screen too even if that's the only thing displayed. We don't mind if the app can only be seen by one user (the user it's installed for).
ClickOnce is a good solution to this problem. If you go to Project Properties > Publish, you can setup settings for this. In particular, "Install Mode and Settings" is good to look at:
The application is available online only -- this is effectively a "run once" application
The application is avaiable offline as well (launchable from Start Menu) -- this installs the app on the PC
You don't actually have to use the ClickOnce web deployment stuff. If you do a Build > Publish, and then zip up the contents of the publish\ folder, you can effectively distribute that as an installer. To make it even smoother, create a self-extracting archive from the folder that automatically runs the setup.exe file.
Even if you install this way, if you opt to use it, the online update will still work for the application. All you have to do is put the ClickOnce files online, and put the URL in the project's Publish properties page.
Vista is more restrictive about this kind of thing, so if you can't do it for XP you can bet Vista won't let you either.
You are right that installing to the program files folder using windows installer requires administrative permissions. In fact, all write access to that folder requires admin permsissions, which is why you should no longer store your data in the same folder as your executable.
Fortunately, if you're using .Net you can use ClickOnce deployment instead of an msi, which should allow you to install to a folder in each user's profile without requiring admin permissions.
The only way that I know of to do this is to build a ClickOnce application in .NET 2.0+
If the user of your application has the correct pre-requsits installed then the application can just be "launched".
Check out:
Microsoft Family.Show
IF UAC is enabled, you couldn't write to Program Files. Installing to \AppData will indeed only install the program for one user.
However, you must note that any configuration changes that require changes to the registry probably(I'd have to double check on that) administrator privilege. Off the top of my head modifications to the desktop background are ultimately stored in HKEY_CURRENT_USER.

Resources