Readme.html 16 KB

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