Readme.html 15 KB

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