Readme.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html lang="en">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <meta name="color-scheme" content="light dark">
  7. <title>Multi-User Header File (MultiUser.nsh)</title>
  8. <style type="text/css">
  9. :root { color-scheme: light dark; }
  10. html, body { font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: normal; color: #050505; background-color: #fefefe; }
  11. html { font-size: 0.9em; }
  12. body { font-size: 1em; font-size: 1rem; }
  13. pre, code { font-family: Courier New, Courier, monospace,serif; font-size: 100%; }
  14. pre, pre code {background-color: #f6f6f6; }
  15. tr:nth-child(odd) { background-color: #fafafa; }
  16. table, tr, td { border: 1px solid #dddddd; border-collapse: collapse; }
  17. td { padding: 0.3em; vertical-align: top; }
  18. @media (prefers-color-scheme: dark) {
  19. html, body { color: #eeeeee; background-color: #161616; }
  20. a, a:link, a:visited, a:active { color: #79b; } a:hover { color: #3ad; }
  21. pre, pre code {background-color: #202020; }
  22. table, tr, td { border-color: #202020; }
  23. tr:nth-child(odd) { background-color: #181818; }
  24. }
  25. </style>
  26. </head>
  27. <body>
  28. <h1>Multi-User Header File (MultiUser.nsh)</h1>
  29. <p><i>Installer configuration for multi-user Windows environments</i></p>
  30. <h2>Table of Contents</h2>
  31. <ul>
  32. <li><a href="#introduction">Introduction</a></li>
  33. <li><a href="#executionlevel">Initialization and Execution Level</a>
  34. <li><a href="#installationmode">Installation Mode</a>
  35. <li><a href="#examples">Example</a>
  36. </ul>
  37. <h2><a name="introduction"></a>Introduction</h2>
  38. <p>
  39. Modern Windows versions support multiple users accounts on a single computer, each
  40. with different privileges. For security reasons, the privileges of applications
  41. can also be limited. For an installer, the <i>execution level</i> and <i>installation
  42. mode</i> are important. The execution level determines the privileges of the
  43. installer application. For example, to install hardware drivers, administrator privileges
  44. are required. Applications can also be installed for a single user or for all users
  45. on a computer, which is determined by the installation mode. Installation for all
  46. users requires a higher execution level as compared with a single user setup. The
  47. MultiUser.nsh header files provides the features to automatically handle all these
  48. aspects related to user accounts and installer privileges.</p>
  49. <p>
  50. Note that all settings need to be set before including the MultiUser.nsh header
  51. file.</p>
  52. <h2>Initialization and <a name="executionlevel"></a>Execution Level&nbsp;</h2>
  53. <p>
  54. Before the MultiUser.nsh file is included, the MULTIUSER_EXECUTIONLEVEL define should
  55. be set to one of the following values depending on the execution level that is required:</p>
  56. <table>
  57. <tr>
  58. <td>
  59. <b>Value </b>
  60. </td>
  61. <td>
  62. <b>Description</b>
  63. </td>
  64. <td>
  65. <b>Typical application</b>
  66. </td>
  67. </tr>
  68. <tr>
  69. <td>
  70. Admin
  71. </td>
  72. <td>
  73. Administrator privileges are required
  74. </td>
  75. <td>
  76. Access data of all users accounts
  77. </td>
  78. </tr>
  79. <tr>
  80. <td>
  81. Power
  82. </td>
  83. <td>
  84. Power User privileges are required<br>
  85. (Power Users no longer exist in Windows Vista. For Vista this is equivalent to Admin)
  86. </td>
  87. <td>
  88. Installation for all users (writing to &quot;Program Files&quot; or HKLM registry
  89. keys), driver installation
  90. </td>
  91. </tr>
  92. <tr>
  93. <td>
  94. Highest
  95. </td>
  96. <td>
  97. Request the highest possible execution level for the current user
  98. </td>
  99. <td>
  100. Mixed-mode installer that can both be installed per-machine or per-user
  101. </td>
  102. </tr>
  103. <tr>
  104. <td>
  105. Standard
  106. </td>
  107. <td>
  108. No special rights required
  109. </td>
  110. <td>
  111. Installation for current user only
  112. </td>
  113. </tr>
  114. </table>
  115. <p>
  116. Insert the MULTIUSER_INIT and MULTIUSER_UNINT macros in the .onInit and un.onInit
  117. function to verify these privileges. If no uninstaller is created in the script,
  118. define MULTIUSER_NOUNINSTALL.</p>
  119. <pre><code>!define MULTIUSER_EXECUTIONLEVEL Highest
  120. ;!define MULTIUSER_NOUNINSTALL ;Uncomment if no uninstaller is created
  121. !include MultiUser.nsh
  122. ...
  123. Function .onInit
  124. !insertmacro MULTIUSER_INIT
  125. FunctionEnd
  126. Function un.onInit
  127. !insertmacro MULTIUSER_UNINIT
  128. FunctionEnd</code></pre>
  129. <p>
  130. Whether the required privileges can be obtained depends on the user that starts
  131. the installer:</p>
  132. <ul>
  133. <li>Windows NT 4/2000/XP/2003 give the installer the same privileges as the user itself.
  134. If the privileges of the user are not sufficient (e.g. Admin level is required is
  135. set but the user has no administrator rights), the macros will display an error
  136. message and quit the installer. If is however possible to manually run the installer
  137. with an administrator account.</li>
  138. <li>Windows Vista restricts the privileges of all applications by default. Depending
  139. on requested execution level, MultiUser.nsh will set the RequestExecutionLevel flag
  140. to request privileges. The user will be asked for confirmation and (if necessary)
  141. for an administrator password.</li>
  142. <li>Windows 95/98/98 do not set any restrictions on users or applications. Administrator
  143. rights are always available.</li>
  144. </ul>
  145. <p>
  146. It is recommended to insert these initialization macros before macros that require
  147. user intervention. For example, it does not make sense to ask a user for an installer
  148. language if the installer will quit afterwards because the user account does not
  149. have the required privileges. After the macros are inserted, the variable $MultiUser.Privileges
  150. will contain the current execution level (Admin, Power, User or Guest).</p>
  151. <p>
  152. The following additional settings are available to customize the initialization:</p>
  153. <table>
  154. <tr>
  155. <td><b>Setting</b></td>
  156. <td><b>Description</b></td>
  157. </tr>
  158. <tr>
  159. <td>
  160. MULTIUSER_INIT_TEXT_ADMINREQUIRED
  161. </td>
  162. <td>
  163. Error message to be displayed when administrator rights are required but not available.
  164. </td>
  165. </tr>
  166. <tr>
  167. <td>
  168. MULTIUSER_INIT_TEXT_POWERREQUIRED
  169. </td>
  170. <td>
  171. Error message to be displayed when Power User rights are required but not available.
  172. </td>
  173. </tr>
  174. <tr>
  175. <td>
  176. MULTIUSER_INIT_TEXT_ALLUSERSNOTPOSSIBLE
  177. </td>
  178. <td>
  179. Error message to be displayed when administrator or Power User rights are required
  180. because of an installation mode setting on the command line (see below) but are
  181. not available.
  182. </td>
  183. </tr>
  184. <tr>
  185. <td>
  186. MULTIUSER_USE_PROGRAMFILES64
  187. </td>
  188. <td>
  189. Use $PROGRAMFILES64 instead of $PROGRAMFILES as the default all users directory.
  190. </td>
  191. </tr>
  192. <tr>
  193. <td>
  194. MULTIUSER_INIT_FUNCTIONQUIT<br>
  195. MULTIUSER_INIT_UNFUNCTIONQUIT
  196. </td>
  197. <td>
  198. A custom function to be called when the installer is closed due to insufficient
  199. privileges.
  200. </td>
  201. </tr>
  202. </table>
  203. <h2><a name="installationmode"></a>Installation Mode</h2>
  204. <p>
  205. As mentioned before, applications can both be installed for a single users or for
  206. all users on a computer. Applications for all users are typically installed in the
  207. Program Files folder and appear in the Start Menu of every user. On the contrary,
  208. applications for a single user are usually installed in the local Application Data
  209. folder and only a appear in the Start Menu of the user who installed the application.</p>
  210. <p>
  211. By default, MultiUser.nsh will set the installation mode for a per-machine installation
  212. if Administrator or Power User rights are available (this is always the case if
  213. the execution level is set to Admin or Power, if Highest is set it depends on the
  214. user account). For the Standard execution level the installation will always be
  215. for a single user. On Windows 95/98/Me installation for a single user is not possible, a per-machine installation will be performed.</p>
  216. <p>
  217. The following settings are available to change the default installation mode:
  218. <table>
  219. <tr>
  220. <td><b>Setting</b></td>
  221. <td><b>Description</b></td>
  222. </tr>
  223. <tr>
  224. <td>
  225. MULTIUSER_INSTALLMODE_DEFAULT_CURRENTUSER
  226. </td>
  227. <td>
  228. Set default to a per-user installation, even if the rights for a per-machine installation
  229. are available.
  230. </td>
  231. </tr>
  232. <tr>
  233. <td>
  234. MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME
  235. </td>
  236. <td>
  237. Non-empty registry key that is created during the installation in either HKCU or
  238. HKLM. The default installation mode will automatically be set to the previously
  239. selected mode depending on the location of the key.
  240. </td>
  241. </tr>
  242. </table>
  243. <p>
  244. After initialization, the variable $MultiUser.InstallMode will contain the current
  245. installation mode (AllUsers or CurrentUser).
  246. </p>
  247. <h3>Mixed-Mode Installation</h3>
  248. <p>
  249. For the Admin and Power levels, both a per-machine as well as a per-user installation
  250. is possible. If the Highest level is set and the user is an Administrator or Power
  251. User, both options are also available.</p>
  252. <p>
  253. Usually it's a good thing to give the user to choice between these options. For
  254. users of the Modern UI version 2, a page is provided that asks the user for the
  255. installation mode. To use this page, define MULTIUSER_MUI before including MultiUser.nsh.
  256. Then, the MULTIUSER_PAGE_INSTALLMODE macro can be used just like a normal Modern
  257. UI page (this page will automatically be skipped when running Windows 95/98/Me):</p>
  258. <pre><code>!define MULTIUSER_EXECUTIONLEVEL Highest
  259. <b>!define MULTIUSER_MUI</b>
  260. !define MULTIUSER_INSTALLMODE_COMMANDLINE
  261. !include MultiUser.nsh
  262. !include MUI2.nsh
  263. <b>!insertmacro MULTIUSER_PAGE_INSTALLMODE</b>
  264. !insertmacro MUI_PAGE_DIRECTORY
  265. !insertmacro MUI_PAGE_INSTFILES
  266. !insertmacro MUI_LANGUAGE English
  267. ...
  268. Function .onInit
  269. !insertmacro MULTIUSER_INIT
  270. FunctionEnd
  271. Function un.onInit
  272. !insertmacro MULTIUSER_UNINIT
  273. FunctionEnd</code></pre>
  274. <p>
  275. The MULTIUSER_INSTALLMODE_COMMANDLINE setting that also appears in this example
  276. enables the installation mode to be set using the /AllUsers or /CurrentUser command
  277. line parameters. This is especially useful for silent setup.</p>
  278. <p>
  279. The following settings can be used to customize the texts on the page (in addition
  280. to the general Modern UI page settings):</p>
  281. <table>
  282. <tr>
  283. <td><b>Setting</b></td>
  284. <td><b>Description</b></td>
  285. </tr>
  286. <tr>
  287. <td>MULTIUSER_INSTALLMODEPAGE_TEXT_TOP</td>
  288. <td>Text to display on the top of the page.</td>
  289. </tr>
  290. <tr>
  291. <td>MULTIUSER_INSTALLMODEPAGE_TEXT_ALLUSERS</td>
  292. <td>Text to display on the radio button for a per-machine installation.</td>
  293. </tr>
  294. <tr>
  295. <td>MULTIUSER_INSTALLMODEPAGE_TEXT_CURRENTUSER</td>
  296. <td>Text to display on the radio button for a per-user installation.</td>
  297. </tr>
  298. <tr>
  299. <td>MULTIUSER_INSTALLMODEPAGE_SHOWUSERNAME</td>
  300. <td>Append the username to the per-user radio button.</td>
  301. </tr>
  302. </table>
  303. <h3>Installation Mode Initialization</h3>
  304. <p>
  305. The SetShellVarContext flag (which determines the folders for e.g. shortcuts, like
  306. $DESKTOP) is automatically set depending on the installation mode. In addition,
  307. the following settings can be used to perform additional actions when the installation
  308. mode is initialized:</p>
  309. <table>
  310. <tr>
  311. <td><b>Setting</b></td>
  312. <td><b>Description</b></td>
  313. </tr>
  314. <tr>
  315. <td>MULTIUSER_INSTALLMODE_INSTDIR</td>
  316. <td>
  317. Name of the folder in which to install the application, without a path. This folder
  318. will be located in Program Files for a per-machine installation and in the local
  319. Application Data folder for a per-user installation (if supported).
  320. </td>
  321. </tr>
  322. <tr>
  323. <td>MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME</td>
  324. <td>
  325. Registry key from which to obtain a previously stored installation folder. It will
  326. be retrieved from HKCU for per-user and HKLM for per-machine.
  327. </td>
  328. </tr>
  329. <tr>
  330. <td>
  331. MULTIUSER_INSTALLMODE_FUNCTION<br>
  332. MULTIUSER_INSTALLMODE_UNFUNCTION
  333. </td>
  334. <td>
  335. A custom function to be called during the initialization of the installation mode
  336. to set additional installer settings that depend on the mode
  337. </td>
  338. </table>
  339. <p>
  340. To set the installation mode manually, call one of these four functions:</p>
  341. <table>
  342. <tr>
  343. <td>
  344. <b>Function name</b>
  345. </td>
  346. <td>
  347. <b>Installation mode</b>
  348. </td>
  349. </tr>
  350. <tr>
  351. <td>
  352. MultiUser.InstallMode.AllUsers
  353. </td>
  354. <td>
  355. Installer: Per-machine installation
  356. </td>
  357. </tr>
  358. <tr>
  359. <td>
  360. MultiUser.InstallMode.CurrentUser
  361. <td>
  362. Installer: Per-user installation
  363. </td>
  364. </tr>
  365. <tr>
  366. <td>
  367. un.MultiUser.InstallMode.AllUsers<td>
  368. Uninstaller: Per-machine installation
  369. </td>
  370. </tr>
  371. <tr>
  372. <td>
  373. un.MultiUser.InstallMode.CurrentUser<td>
  374. Uninstaller: Per-user installation
  375. </td>
  376. </tr>
  377. </table>
  378. <h2><a name="examples"></a>Example</h2>
  379. Basic: <a href="../../Examples/MultiUser.nsi">MultiUser.nsi</a><br />
  380. </body>
  381. </html>