Debian Codegraph @

Docs/src/registry.but

raw
1 \S1{registry} Registry, INI, File Instructions
2
3 In all of the below registry instructions use an empty string (just two quotes with nothing between them - "") as the key name to specify the default key which is shown as (Default) in regedit.exe.
4
5 Use \R{setregview}{SetRegView} on 64-bit Windows to choose which registry view is used.
6
7 If a full path is not specified for any of the INI handling instructions, the Windows directory will be used.
8
9 \S2{deleteinisec} DeleteINISec
10
11 \c ini_filename section_name
12
13 Deletes the entire section [section_name] from ini_filename. If the section could not be removed from the ini file, the error flag is set. It does not set the error flag if the section could not be found.
14
15 \c WriteINIStr $TEMP\something.ini section1 something 123
16 \c WriteINIStr $TEMP\something.ini section1 somethingelse 1234
17 \c WriteINIStr $TEMP\something.ini section2 nsis true
18 \c DeleteINISec $TEMP\something.ini section1
19
20 \S2{deleteinistr} DeleteINIStr
21
22 \c ini_filename section_name str_name
23
24 Deletes the string str_name from section [section_name] from ini_filename. If the string could not be removed from the ini file, the error flag is set. It does not set the error flag if the string could not be found.
25
26 \c WriteINIStr $TEMP\something.ini section1 something 123
27 \c WriteINIStr $TEMP\something.ini section1 somethingelse 1234
28 \c DeleteINIStr $TEMP\something.ini section1 somethingelse
29
30 \S2{deleteregkey} DeleteRegKey
31
32 \c [/ifempty | /ifnosubkeys | /ifnovalues] root_key subkey
33
34 Deletes a registry key. If /ifempty is specified, the registry key will only be deleted if it has no subkeys and no values (otherwise, the whole registry tree will be removed). Valid values for root_key are listed under \R{writeregstr}{WriteRegStr}. The error flag is set if the key could not be removed from the registry (or if it didn't exist to begin with).
35
36 \c DeleteRegKey HKLM "Software\My Company\My Software"
37 \c DeleteRegKey /ifempty HKLM "Software\A key that might have subkeys"
38
39 \S2{deleteregvalue} DeleteRegValue
40
41 \c root_key subkey key_name
42
43 Deletes a registry value. Valid values for root_key are listed under \R{writeregstr}{WriteRegStr}. The error flag is set if the value could not be removed from the registry (or if it didn't exist to begin with).
44
45 \c DeleteRegValue HKLM "Software\My Company\My Software" "some value"
46
47 \S2{enumregkey} EnumRegKey
48
49 \c user_var(output) root_key subkey index
50
51 Set user variable $x with the name of the 'index'th registry key in root_key\\Subkey. Valid values for root_key are listed under \R{writeregstr}{WriteRegStr}. Returns an empty string if there are no more keys, and returns an empty string and sets the error flag if there is an error.
52
53 \c StrCpy $0 0
54 \c loop:
55 \c EnumRegKey $1 HKLM Software $0
56 \c StrCmp $1 "" done
57 \c IntOp $0 $0 + 1
58 \c MessageBox MB_YESNO|MB_ICONQUESTION "$1$\n$\nMore?" IDYES loop
59 \c done:
60
61 \S2{enumregvalue} EnumRegValue
62
63 \c user_var(output) root_key subkey index
64
65 Set user variable $x with the name of the 'index'th registry value in root_key\\Subkey. Valid values for root_key are listed under \R{writeregstr}{WriteRegStr}. Returns an empty string and sets the error flag if there are no more values or if there is an error.
66
67 \c StrCpy $0 0
68 \c loop:
69 \c ClearErrors
70 \c EnumRegValue $1 HKLM Software\Microsoft\Windows\CurrentVersion $0
71 \c IfErrors done
72 \c IntOp $0 $0 + 1
73 \c ReadRegStr $2 HKLM Software\Microsoft\Windows\CurrentVersion $1
74 \c MessageBox MB_YESNO|MB_ICONQUESTION "$1 = $2$\n$\nMore?" IDYES loop
75 \c done:
76
77 \S2{expandenvstrings} ExpandEnvStrings
78
79 \c user_var(output) string
80
81 Expands environment variables in \e{string} into the user variable \e{$x}. If an environment variable doesn't exist, it will not be replaced. For example, if you use "%var%" and var doesn't exists, the result will be "%var%". If there is an error, the variable is set to empty, and the error flag is set.
82
83 \c ExpandEnvStrings $0 "WINDIR=%WINDIR%$\nTEMP=%TEMP%"
84
85 \S2{flushini} FlushINI
86
87 \c ini_filename
88
89 Flushes the INI file's buffers. Windows 9x keeps all changes to the INI file in memory. This command causes the changes to be written to the disk immediately. Use it if you edit the INI manually, delete it, move it or copy it right after you change it with \R{writeinistr}{WriteINIStr}, \R{deleteinisec}{DeleteINISec} or \R{deleteinistr}{DeleteINStr}.
90
91 \c WriteINIStr $TEMP\something.ini test test test
92 \c FlushINI $TEMP\something.ini
93 \c Delete $TEMP\something.ini
94
95 \S2{readenvstr} ReadEnvStr
96
97 \c user_var(output) name
98
99 Reads from the environment string "name" and sets the value into the user variable $x. If there is an error reading the string, the user variable is set to empty, and the error flag is set.
100
101 \c ReadEnvStr $0 WINDIR
102 \c ReadEnvStr $1 TEMP
103
104 \S2{readinistr} ReadINIStr
105
106 \c user_var(output) ini_filename section_name entry_name
107
108 Reads from entry_name in [section_name] of ini_filename and stores the value into user variable $x. The error flag will be set and $x will be assigned to an empty string if the entry is not found.
109
110 \c ReadINIStr $0 $INSTDIR\winamp.ini winamp outname
111
112 \S2{readregdword} ReadRegDWORD
113
114 \c user_var(output) root_key sub_key name
115
116 Reads a 32-bit DWORD from the registry into the user variable $x. Valid values for root_key are listed under \R{writeregstr}{WriteRegStr}. The error flag will be set and $x will be set to an empty string ("" which is interpreted as 0 in math operations) if the DWORD is not present. If the value is present, but is not a DWORD, it will be read as a string and the error flag will be set.
117
118 \c ReadRegDWORD $0 HKLM Software\NSIS VersionBuild
119
120 \S2{readregstr} ReadRegStr
121
122 \c user_var(output) root_key sub_key name
123
124 Reads from the registry into the user variable $x. Valid values for root_key are listed under \R{writeregstr}{WriteRegStr}. The error flag will be set and $x will be set to an empty string ("") if the string is not present. If the value is present, but is of type REG_DWORD, it will be read and converted to a string and the error flag will be set.
125
126 \c ReadRegStr $0 HKLM Software\NSIS ""
127 \c DetailPrint "NSIS is installed at: $0"
128
129 \S2{writeinistr} WriteINIStr
130
131 \c ini_filename section_name entry_name value
132
133 Writes entry_name=value into [section_name] of ini_filename. The error flag is set if the string could not be written to the ini file.
134
135 \c WriteINIStr $TEMP\something.ini section1 something 123
136 \c WriteINIStr $TEMP\something.ini section1 somethingelse 1234
137 \c WriteINIStr $TEMP\something.ini section2 nsis true
138
139 \S2{writeregbin} WriteRegBin
140
141 \c root_key subkey key_name valuedata
142
143 This command writes a block of binary data to the registry. Valid values for root_key are listed under \R{writeregstr}{WriteRegStr}. Valuedata is in hexadecimal (e.g. DEADBEEF01223211151). The error flag is set if the binary data could not be written to the registry. If the registry key doesn't exist it will be created.
144
145 \c WriteRegBin HKLM "Software\My Company\My Software" "Binary Value" DEADBEEF01223211151
146
147 \S2{writeregnone} WriteRegNone
148
149 \c root_key subkey key_name
150
151 Writes a value without data to the registry.
152
153 \S2{writeregdword} WriteRegDWORD
154
155 \c root_key subkey key_name value
156
157 This command writes a DWORD (32-bit integer) to the registry (a user variable can be specified). Valid values for root_key are listed under \R{writeregstr}{WriteRegStr}. The error flag is set if the dword could not be written to the registry. If the registry key doesn't exist it will be created.
158
159 \c WriteRegDWORD HKLM "Software\My Company\My Software" "DWORD Value" 0xDEADBEEF
160
161 \S2{writeregstr} WriteRegStr
162
163 \c root_key subkey key_name value
164
165 Write a string to the registry. See \R{writeregexpandstr}{WriteRegExpandStr} for more details.
166
167 \c WriteRegStr HKLM "Software\My Company\My Software" "String Value" "dead beef"
168
169 \S2{writeregexpandstr} WriteRegExpandStr
170
171 \c root_key subkey key_name value
172
173 Write a string to the registry. \e{root_key} must be one of:
174
175 \b \e{HKCR} or \e{HKEY_CLASSES_ROOT}
176
177 \b \e{HKLM} or \e{HKEY_LOCAL_MACHINE}
178
179 \b \e{HKCU} or \e{HKEY_CURRENT_USER}
180
181 \b \e{HKU} or \e{HKEY_USERS}
182
183 \b \e{HKCC} or \e{HKEY_CURRENT_CONFIG}
184
185 \b \e{HKDD} or \e{HKEY_DYN_DATA}
186
187 \b \e{HKPD} or \e{HKEY_PERFORMANCE_DATA}
188
189 \b \e{SHCTX} or \e{SHELL_CONTEXT}
190
191 \b \e{HKCR32} or \e{HKCR64}
192
193 \b \e{HKCU32} or \e{HKCU64}
194
195 \b \e{HKLM32} or \e{HKLM64}
196
197 If \e{root_key} is \e{SHCTX} or \e{SHELL_CONTEXT}, it will be replaced with \e{HKLM} if \R{setshellvarcontext}{SetShellVarContext} is set to \e{all} and with \e{HKCU} if \R{setshellvarcontext}{SetShellVarContext} is set to \e{current}.
198
199 The error flag is set if the string could not be written to the registry. The type of the string will be REG_SZ for \R{writeregstr}{WriteRegStr}, or REG_EXPAND_STR for \R{writeregexpandstr}{WriteRegExpandStr}. If the registry key doesn't exist it will be created.
200
201 \c WriteRegExpandStr HKLM "Software\My Company\My Software" "Expand String Value" "%WINDIR%\notepad.exe"
202
203 \S2{writeregmultistr} WriteRegMultiStr
204
205 \c /REGEDIT5 root_key subkey key_name value
206
207 Writes a multi-string value. The /REGEDIT5 switch must be used and specifies that the data is in the hex format used by .reg files on Windows 2000 and later.
208
209 \c WriteRegMultiStr /REGEDIT5 HKCU "Software\NSIS\Test" "Multi Value" 66,00,6f,00,6f,00,00,00,62,00,61,00,72,00,00,00,00,00
210
211 \S2{setregview} SetRegView
212
213 \c 32|64|\\<b\\>default\\</b\\>|lastused
214
215 Sets the registry view affected by \R{registry}{registry commands} (root keys with a 32/64 suffix are not affected). On 64-bit versions of Windows there are two views; one for 32-bit applications and one for 64-bit applications. By default, 32-bit applications running on 64-bit systems (WOW64) only have access to the 32-bit view. Using \c{SetRegView 64} allows the installer to access keys in the 64-bit view of the registry. Registry operations will fail if the selected view is not supported by Windows.
216
217 Affects \R{deleteregkey}{DeleteRegKey}, \R{deleteregvalue}{DeleteRegValue}, \R{enumregkey}{EnumRegKey}, \R{enumregvalue}{EnumRegValue}, \R{readregdword}{ReadRegDWORD}, \R{readregstr}{ReadRegStr}, \R{writeregbin}{WriteRegBin}, \R{writeregdword}{WriteRegDWORD}, \R{writeregstr}{WriteRegStr} and \R{writeregexpandstr}{WriteRegExpandStr}.
218
219 Does not affect \R{ainstalldirregkey}{InstallDirRegKey}. Instead, the registry must be read using \R{readregstr}{ReadRegStr} in \R{oninit}{.onInit}.
220
221 \c SetRegView 32
222 \c ReadRegStr $0 HKLM Software\Microsoft\Windows\CurrentVersion ProgramFilesDir
223 \c DetailPrint $0 # prints C:\Program Files (x86)
224 \c !include x64.nsh
225 \c ${If} ${RunningX64}
226 \c SetRegView 64
227 \c ReadRegStr $0 HKLM Software\Microsoft\Windows\CurrentVersion ProgramFilesDir
228 \c DetailPrint $0 # prints C:\Program Files
229 \c ${EndIf}
230 \c SetRegView Default