Archive: Install for current user or all?


Install for current user or all?
What would you have to do to install an application for just one user? For all users? Does it have to do with registry keys?


On Windows computers there usually is only one directory to install programs, which is used by *all* users. That is "C:\Program Files" aka $PROGRAMS. You might need admin rights to install a program there though. The Registry has one root key to store system-wide settings (read access for all users, write access for admin only) and one root key to store the user's personal settings (full access for all users). Those are HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER. The Startmenu has folders for all users and for single users. That is: "C:\Documents and Settings\All Users\Start Menu\Programs" and "C:\Documents and Settings\John Doe\Start Menu\Programs". Both accessible via $SMPROGRAMS, depending on ShellVarContext.


Take a look at the documentation for SetShellVarContext. It was written for the issues that you're talking about. By setting the context you can decide whether your program makes shortcuts for a single user or for the machine.

Obviously, files that are copied to your machine during setup are visible to all users unless privileges are applied to a directory, but you can determine who the preferences are set up for. And, if you install keys to your HKCU portion of the registry, you can make it very difficult for another person who hasn't run the installation to use your program if that's what you're looking to do.