[9f577259] | 1 | #!/bin/bash |
---|
| 2 | #/** |
---|
| 3 | #@file Registry.lib |
---|
| 4 | #@brief Librería o clase Registry |
---|
| 5 | #@class Boot |
---|
| 6 | #@brief Funciones para gestión del registro de Windows. |
---|
[0dbb5f7] | 7 | #@version 1.0.5 |
---|
[9f577259] | 8 | #@warning License: GNU GPLv3+ |
---|
| 9 | #*/ |
---|
| 10 | |
---|
| 11 | |
---|
[0dbb5f7] | 12 | # Función ficticia para lanzar chntpw con timeout de 5 s., evitando cuelgues del programa. |
---|
| 13 | function chntpw () |
---|
| 14 | { |
---|
| 15 | local CHNTPW |
---|
| 16 | CHNTPW=$(which drbl-chntpw) |
---|
| 17 | CHNTPW=${CHNTPW:-$(which chntpw)} |
---|
| 18 | timeout --foreground 5s $CHNTPW "$@" |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | |
---|
[9f577259] | 22 | #/** |
---|
| 23 | # ogAddRegistryKey path_mountpoint str_hive str_keyname |
---|
| 24 | #@brief Añade una nueva clave al registro de Windows. |
---|
[bf18bcbd] | 25 | #@param path_mountpoint directorio donde está montado el sistema Windows |
---|
| 26 | #@param str_hive sección del registro |
---|
| 27 | #@param str_keyname nombre de la clave |
---|
| 28 | #@return (nada) |
---|
| 29 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 30 | #@exception OG_ERR_NOTFOUND Fichero de registro no encontrado. |
---|
| 31 | #@note hive = { default, sam, security, software, system, components } |
---|
| 32 | #@warning Requisitos: chntpw |
---|
| 33 | #@warning El sistema de archivos de Windows debe estar montada previamente. |
---|
[9f577259] | 34 | #@version 1.0.1 - Nueva función |
---|
| 35 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
[cd2ae87] | 36 | #@date 2011-05-25 |
---|
[9f577259] | 37 | #*/ ## |
---|
[1b804cc] | 38 | function ogAddRegistryKey () |
---|
[9f577259] | 39 | { |
---|
[cd2ae87] | 40 | # Variables locales. |
---|
| 41 | local FILE |
---|
[9f577259] | 42 | |
---|
[cd2ae87] | 43 | # Si se solicita, mostrar ayuda. |
---|
| 44 | if [ "$*" == "help" ]; then |
---|
[bf18bcbd] | 45 | ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_key" \ |
---|
| 46 | "$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\NewKey'" |
---|
[cd2ae87] | 47 | return |
---|
| 48 | fi |
---|
| 49 | # Error si no se reciben 3 parámetros. |
---|
| 50 | [ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 51 | # Camino del fichero de registro. |
---|
| 52 | FILE=$(ogGetHivePath "$1" "$2") || return $? |
---|
[9f577259] | 53 | |
---|
[cd2ae87] | 54 | # Añadir nueva clave. |
---|
[367e04d] | 55 | chntpw "$FILE" << EOT &> /dev/null |
---|
[3907aaf] | 56 | cd ${3%\\*} |
---|
| 57 | nk ${3##*\\} |
---|
[cd2ae87] | 58 | q |
---|
| 59 | y |
---|
| 60 | EOT |
---|
[1b804cc] | 61 | } |
---|
| 62 | |
---|
| 63 | #/** |
---|
[9570719] | 64 | # ogAddRegistryValue path_mountpoint str_hive str_valuename [str_valuetype] |
---|
| 65 | #@brief Añade un nuevo valor al registro de Windows, indicando su tipo de datos. |
---|
[bf18bcbd] | 66 | #@param path_mountpoint directorio donde está montado el sistema Windows |
---|
| 67 | #@param str_hive sección del registro |
---|
| 68 | #@param str_valuename nombre del valor |
---|
| 69 | #@param str_valuetype tipo de datos del valor (opcional) |
---|
| 70 | #@return (nada) |
---|
| 71 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 72 | #@exception OG_ERR_NOTFOUND Fichero de registro no encontrado. |
---|
[1cd64e6] | 73 | #@note hive = { DEFAULT, SAM, SECURITY, SOFTWARE, SYSTEM, COMPONENTS } |
---|
| 74 | #@note valuetype = { STRING, BINARY, DWORD }, por defecto: STRING |
---|
[bf18bcbd] | 75 | #@warning Requisitos: chntpw |
---|
| 76 | #@warning El sistema de archivos de Windows debe estar montada previamente. |
---|
[1b804cc] | 77 | #@version 1.0.1 - Nueva función |
---|
| 78 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
[9570719] | 79 | #@date 2011-05-25 |
---|
[1b804cc] | 80 | #*/ ## |
---|
[cd2ae87] | 81 | function ogAddRegistryValue () |
---|
[1b804cc] | 82 | { |
---|
[9570719] | 83 | # Variables locales. |
---|
| 84 | local FILE TYPE |
---|
| 85 | |
---|
| 86 | # Si se solicita, mostrar ayuda. |
---|
| 87 | if [ "$*" == "help" ]; then |
---|
[bf18bcbd] | 88 | ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_valuename [str_valuetype]" \ |
---|
| 89 | "$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\NewKey\Value1'" \ |
---|
| 90 | "$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\NewKey\Value1' DWORD" |
---|
[9570719] | 91 | return |
---|
| 92 | fi |
---|
| 93 | # Error si no se reciben 3 o 4 parámetros. |
---|
| 94 | [ $# == 3 -o $# == 4 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 95 | # Camino del fichero de registro. |
---|
| 96 | FILE=$(ogGetHivePath "$1" "$2") || return $? |
---|
| 97 | case "$4" in |
---|
| 98 | string|STRING|"") TYPE=1 ;; |
---|
| 99 | binary|BINARY) TYPE=3 ;; |
---|
| 100 | dword|DWORD) TYPE=4 ;; |
---|
| 101 | *) ogRaiseError $OG_ERR_OUTOFLIMIT "$4" |
---|
[367e04d] | 102 | return $? ;; |
---|
[9570719] | 103 | esac |
---|
| 104 | |
---|
| 105 | # Devolver el dato del valor de registro. |
---|
| 106 | # /* (comentario Doxygen) |
---|
[367e04d] | 107 | chntpw "$FILE" << EOT &> /dev/null |
---|
[9570719] | 108 | cd ${3%\\*} |
---|
| 109 | nv $TYPE ${3##*\\} |
---|
| 110 | q |
---|
| 111 | y |
---|
| 112 | EOT |
---|
| 113 | # (comentario Doxygen) */ |
---|
[1b804cc] | 114 | } |
---|
| 115 | |
---|
| 116 | |
---|
| 117 | #/** |
---|
| 118 | # ogDeleteRegistryKey path_mountpoint str_hive str_keyname |
---|
| 119 | #@brief Elimina una clave del registro de Windows con todo su contenido. |
---|
[bf18bcbd] | 120 | #@param path_mountpoint directorio donde está montado el sistema Windows |
---|
| 121 | #@param str_hive sección del registro |
---|
| 122 | #@param str_keyname nombre de la clave |
---|
| 123 | #@return (nada) |
---|
| 124 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 125 | #@exception OG_ERR_NOTFOUND Fichero de registro no encontrado. |
---|
| 126 | #@note hive = { default, sam, security, software, system, components } |
---|
| 127 | #@warning Requisitos: chntpw |
---|
| 128 | #@warning El sistema de archivos de Windows debe estar montada previamente. |
---|
| 129 | #@warning La clave debe estar vacía para poder ser borrada. |
---|
[1b804cc] | 130 | #@version 1.0.1 - Nueva función |
---|
| 131 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
[cd2ae87] | 132 | #@date 2011-05-25 |
---|
[1b804cc] | 133 | #*/ ## |
---|
| 134 | function ogDeleteRegistryKey () |
---|
| 135 | { |
---|
[cd2ae87] | 136 | # Variables locales. |
---|
| 137 | local FILE |
---|
| 138 | |
---|
| 139 | # Si se solicita, mostrar ayuda. |
---|
| 140 | if [ "$*" == "help" ]; then |
---|
[bf18bcbd] | 141 | ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_key" \ |
---|
| 142 | "$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\NewKey'" |
---|
[cd2ae87] | 143 | return |
---|
| 144 | fi |
---|
| 145 | # Error si no se reciben 3 parámetros. |
---|
| 146 | [ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 147 | # Camino del fichero de registro. |
---|
| 148 | FILE=$(ogGetHivePath "$1" "$2") || return $? |
---|
| 149 | |
---|
| 150 | # Añadir nueva clave. |
---|
[367e04d] | 151 | chntpw "$FILE" << EOT &> /dev/null |
---|
[3907aaf] | 152 | cd ${3%\\*} |
---|
| 153 | dk ${3##*\\} |
---|
[cd2ae87] | 154 | q |
---|
| 155 | y |
---|
| 156 | EOT |
---|
[1b804cc] | 157 | } |
---|
| 158 | |
---|
[1cd64e6] | 159 | |
---|
[1b804cc] | 160 | #/** |
---|
[bf18bcbd] | 161 | # ogDeleteRegistryValue path_mountpoint str_hive str_valuename |
---|
[1b804cc] | 162 | #@brief Elimina un valor del registro de Windows. |
---|
[bf18bcbd] | 163 | #@param path_mountpoint directorio donde está montado el sistema Windows |
---|
| 164 | #@param str_hive sección del registro |
---|
| 165 | #@param str_valuename nombre del valor |
---|
| 166 | #@return (nada) |
---|
| 167 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 168 | #@exception OG_ERR_NOTFOUND Fichero de registro no encontrado. |
---|
| 169 | #@note hive = { default, sam, security, software, system, components } |
---|
| 170 | #@warning Requisitos: chntpw |
---|
| 171 | #@warning El sistema de archivos de Windows debe estar montada previamente. |
---|
[1b804cc] | 172 | #@version 1.0.1 - Nueva función |
---|
| 173 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
[cd2ae87] | 174 | #@date 2011-05-25 |
---|
[1b804cc] | 175 | #*/ ## |
---|
| 176 | function ogDeleteRegistryValue () |
---|
| 177 | { |
---|
[cd2ae87] | 178 | # Variables locales. |
---|
| 179 | local FILE |
---|
| 180 | |
---|
| 181 | # Si se solicita, mostrar ayuda. |
---|
| 182 | if [ "$*" == "help" ]; then |
---|
[bf18bcbd] | 183 | ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_valuename" \ |
---|
| 184 | "$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\NewKey\Value1'" |
---|
[cd2ae87] | 185 | return |
---|
| 186 | fi |
---|
| 187 | # Error si no se reciben 3 parámetros. |
---|
| 188 | [ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 189 | # Camino del fichero de registro. |
---|
| 190 | FILE=$(ogGetHivePath "$1" "$2") || return $? |
---|
| 191 | |
---|
| 192 | # Devolver el dato del valor de registro. |
---|
| 193 | # /* (comentario Doxygen) |
---|
[367e04d] | 194 | chntpw "$FILE" << EOT &> /dev/null |
---|
[cd2ae87] | 195 | cd ${3%\\*} |
---|
| 196 | dv ${3##*\\} |
---|
| 197 | q |
---|
| 198 | y |
---|
| 199 | EOT |
---|
| 200 | # (comentario Doxygen) */ |
---|
[1b804cc] | 201 | } |
---|
| 202 | |
---|
| 203 | |
---|
| 204 | #/** |
---|
| 205 | # ogGetHivePath path_mountpoint str_hive |
---|
[9f577259] | 206 | #@brief Función básica que devuelve el camino del fichero con una sección del registro. |
---|
| 207 | #@param path_mountpoint directorio donde está montado el sistema Windows |
---|
| 208 | #@param str_hive sección del registro |
---|
| 209 | #@return str_path - camino del fichero de registro |
---|
| 210 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
[bf18bcbd] | 211 | #@exception OG_ERR_NOTFOUND Fichero de registro no encontrado. |
---|
[1cd64e6] | 212 | #@note hive = { DEFAULT, SAM, SECURITY, SOFTWARE, SYSTEM, COMPONENTS } |
---|
[9f577259] | 213 | #@warning El sistema de archivos de Windows debe estar montada previamente. |
---|
| 214 | #@version 1.0.1 - Nueva función |
---|
| 215 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 216 | #@date 2011-05-18 |
---|
| 217 | #*/ ## |
---|
[1b804cc] | 218 | function ogGetHivePath () |
---|
[9f577259] | 219 | { |
---|
| 220 | # Variables locales. |
---|
| 221 | local FILE FILENT FILEXP |
---|
| 222 | |
---|
| 223 | # Si se solicita, mostrar ayuda. |
---|
| 224 | if [ "$*" == "help" ]; then |
---|
| 225 | ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive" |
---|
[1cd64e6] | 226 | "$FUNCNAME /mnt/sda1 SOFTWARE => /mnt/sda1/WINDOWS/System32/config/SOFTWARE" |
---|
[9f577259] | 227 | return |
---|
| 228 | fi |
---|
| 229 | # Error si no se reciben 2 parámetros. |
---|
| 230 | [ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 231 | |
---|
| 232 | # Camino del fichero de registro en NT/2000 o XP/Vista/7. |
---|
| 233 | FILENT=$(ogGetPath "/$1/winnt/system32/config/$2") |
---|
| 234 | [ -f $FILENT ] && FILE="$FILENT" |
---|
| 235 | FILEXP=$(ogGetPath "/$1/windows/system32/config/$2") |
---|
| 236 | [ -f $FLEHXP ] && FILE="$FILEXP" |
---|
| 237 | [ ! -f $FILE ] && ogRaiseError OG_ERR_NOTFOUND "$1,$2" && return $? |
---|
| 238 | |
---|
| 239 | echo "$FILE" |
---|
| 240 | } |
---|
| 241 | |
---|
| 242 | |
---|
| 243 | #/** |
---|
| 244 | # ogGetRegistryValue path_mountpoint str_hive str_valuename |
---|
| 245 | #@brief Devuelve el dato de un valor del registro de Windows. |
---|
| 246 | #@param path_mountpoint directorio donde está montado el sistema Windows |
---|
| 247 | #@param str_hive sección del registro |
---|
| 248 | #@param str_valuename nombre del valor |
---|
| 249 | #@return str_valuedata - datos del valor. |
---|
| 250 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
[bf18bcbd] | 251 | #@exception OG_ERR_NOTFOUND Fichero de registro no encontrado. |
---|
[9f577259] | 252 | #@note hive = { default, sam, security, software, system, components } |
---|
| 253 | #@warning Requisitos: chntpw, awk |
---|
[bf18bcbd] | 254 | #@warning El sistema de archivos de Windows debe estar montado previamente. |
---|
[9f577259] | 255 | #@version 0.9 - Adaptación para OpenGNSys. |
---|
| 256 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 257 | #@date 2009-09-11 |
---|
| 258 | #*/ ## |
---|
| 259 | function ogGetRegistryValue () |
---|
| 260 | { |
---|
| 261 | # Variables locales. |
---|
| 262 | local FILE |
---|
| 263 | |
---|
| 264 | # Si se solicita, mostrar ayuda. |
---|
| 265 | if [ "$*" == "help" ]; then |
---|
[bf18bcbd] | 266 | ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_valuename" \ |
---|
| 267 | "$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\NewKey\Value1' ==> 1" |
---|
[9f577259] | 268 | return |
---|
| 269 | fi |
---|
| 270 | # Error si no se reciben 3 parámetros. |
---|
| 271 | [ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 272 | # Camino del fichero de registro. |
---|
[1b804cc] | 273 | FILE=$(ogGetHivePath "$1" "$2") || return $? |
---|
[9f577259] | 274 | |
---|
| 275 | # Devolver el dato del valor de registro. |
---|
| 276 | # /* (comentario Doxygen) |
---|
[367e04d] | 277 | chntpw "$FILE" << EOT 2> /dev/null | awk '/> Value/ {getline;print $0;}' |
---|
[9f577259] | 278 | cd ${3%\\*} |
---|
| 279 | cat ${3##*\\} |
---|
| 280 | q |
---|
[cd2ae87] | 281 | EOT |
---|
[9f577259] | 282 | # (comentario Doxygen) */ |
---|
| 283 | } |
---|
| 284 | |
---|
| 285 | |
---|
| 286 | #/** |
---|
[3907aaf] | 287 | # ogListRegistryKeys path_mountpoint str_hive str_key |
---|
| 288 | #@brief Lista los nombres de subclaves de una determinada clave del registro de Windows. |
---|
[9f577259] | 289 | #@param path_mountpoint directorio donde está montado el sistema Windows |
---|
| 290 | #@param str_hive sección del registro |
---|
| 291 | #@param str_key clave de registro |
---|
| 292 | #@return str_subkey ... - lista de subclaves |
---|
| 293 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
[bf18bcbd] | 294 | #@exception OG_ERR_NOTFOUND Fichero de registro no encontrado. |
---|
[9f577259] | 295 | #@note hive = { default, sam, security, software, system, components } |
---|
| 296 | #@warning Requisitos: chntpw, awk |
---|
[bf18bcbd] | 297 | #@warning El sistema de archivos de Windows debe estar montado previamente. |
---|
[9f577259] | 298 | #@version 0.9 - Adaptación para OpenGNSys. |
---|
| 299 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 300 | #@date 2009-09-23 |
---|
| 301 | #*/ ## |
---|
[3907aaf] | 302 | function ogListRegistryKeys () |
---|
[9f577259] | 303 | { |
---|
| 304 | # Variables locales. |
---|
| 305 | local FILE |
---|
| 306 | |
---|
| 307 | # Si se solicita, mostrar ayuda. |
---|
| 308 | if [ "$*" == "help" ]; then |
---|
[bf18bcbd] | 309 | ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_key" \ |
---|
| 310 | "$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\Windows\CurrentVersion'" |
---|
[9f577259] | 311 | return |
---|
| 312 | fi |
---|
| 313 | # Error si no se reciben 3 parámetros. |
---|
| 314 | [ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 315 | |
---|
| 316 | # Camino del fichero de registro. |
---|
[1b804cc] | 317 | FILE=$(ogGetHivePath "$1" "$2") || return $? |
---|
[9f577259] | 318 | |
---|
| 319 | # Devolver la lista de claves de registro. |
---|
[367e04d] | 320 | chntpw "$FILE" << EOT 2> /dev/null | awk 'BEGIN {FS="[<>]"} $1~/^ $/ {print $2}' |
---|
[9f577259] | 321 | ls $3 |
---|
| 322 | q |
---|
[9570719] | 323 | EOT |
---|
[9f577259] | 324 | } |
---|
| 325 | |
---|
| 326 | |
---|
| 327 | #/** |
---|
[3907aaf] | 328 | # ogListRegistryValues path_mountpoint str_hive str_key |
---|
| 329 | #@brief Lista los nombres de valores de una determinada clave del registro de Windows. |
---|
[bf18bcbd] | 330 | #@param path_mountpoint directorio donde está montado el sistema Windows |
---|
| 331 | #@param str_hive sección del registro |
---|
| 332 | #@param str_key clave de registro |
---|
| 333 | #@return str_value ... - lista de valores |
---|
| 334 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 335 | #@exception OG_ERR_NOTFOUND Fichero de registro no encontrado. |
---|
| 336 | #@note hive = { default, sam, security, software, system, components } |
---|
| 337 | #@warning Requisitos: chntpw, awk |
---|
| 338 | #@warning El sistema de archivos de Windows debe estar montado previamente. |
---|
[3907aaf] | 339 | #@version 1.0.1 - Nueva función. |
---|
| 340 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 341 | #@date 2011-05-26 |
---|
| 342 | #*/ ## |
---|
| 343 | function ogListRegistryValues () |
---|
| 344 | { |
---|
| 345 | # Variables locales. |
---|
| 346 | local FILE |
---|
| 347 | |
---|
| 348 | # Si se solicita, mostrar ayuda. |
---|
| 349 | if [ "$*" == "help" ]; then |
---|
[bf18bcbd] | 350 | ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_key" \ |
---|
| 351 | "$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\Windows\CurrentVersion'" |
---|
[3907aaf] | 352 | return |
---|
| 353 | fi |
---|
| 354 | # Error si no se reciben 3 parámetros. |
---|
| 355 | [ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 356 | # Camino del fichero de registro. |
---|
| 357 | FILE=$(ogGetHivePath "$1" "$2") || return $? |
---|
| 358 | |
---|
| 359 | # Devolver la lista de claves de registro. |
---|
[367e04d] | 360 | chntpw "$FILE" << EOT 2> /dev/null | awk 'BEGIN {FS="[<>]"} $1~/REG_/ {print $2}' |
---|
[3907aaf] | 361 | ls $3 |
---|
| 362 | q |
---|
| 363 | EOT |
---|
| 364 | } |
---|
| 365 | |
---|
| 366 | |
---|
| 367 | #/** |
---|
[9f577259] | 368 | # ogSetRegistryValue path_mountpoint str_hive str_valuename str_valuedata |
---|
| 369 | #@brief Establece el dato asociado a un valor del registro de Windows. |
---|
| 370 | #@param path_mountpoint directorio donde está montado el sistema Windows |
---|
[bf18bcbd] | 371 | #@param str_hive sección del registro |
---|
[9f577259] | 372 | #@param str_valuename nombre del valor de registro |
---|
| 373 | #@param str_valuedata dato del valor de registro |
---|
| 374 | #@return (nada) |
---|
| 375 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
[bf18bcbd] | 376 | #@exception OG_ERR_NOTFOUND Fichero de registro no encontrado. |
---|
[9f577259] | 377 | #@note hive = { default, sam, security, software, system, components } |
---|
[bf18bcbd] | 378 | #@warning Requisitos: chntpw |
---|
| 379 | #@warning El sistema de archivos de Windows debe estar montado previamente. |
---|
[9f577259] | 380 | #@version 0.9 - Adaptación para OpenGNSys. |
---|
| 381 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 382 | #@date 2009-09-24 |
---|
| 383 | #*/ ## |
---|
| 384 | function ogSetRegistryValue () |
---|
| 385 | { |
---|
| 386 | # Variables locales. |
---|
| 387 | local FILE |
---|
| 388 | |
---|
| 389 | # Si se solicita, mostrar ayuda. |
---|
| 390 | if [ "$*" == "help" ]; then |
---|
| 391 | ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_valuename str_data" |
---|
[bf18bcbd] | 392 | "$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\NewKey\Value1' 1" |
---|
[9f577259] | 393 | return |
---|
| 394 | fi |
---|
| 395 | # Error si no se reciben 4 parámetros. |
---|
| 396 | [ $# == 4 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 397 | # Camino del fichero de registro. |
---|
[1b804cc] | 398 | FILE=$(ogGetHivePath "$1" "$2") || return $? |
---|
[9f577259] | 399 | |
---|
| 400 | # Cambiar el dato del valor de registro. |
---|
[367e04d] | 401 | chntpw "$FILE" << EOT &> /dev/null |
---|
| 402 | cd ${3%\\*} |
---|
| 403 | ed ${3##*\\} |
---|
[9f577259] | 404 | $4 |
---|
| 405 | q |
---|
| 406 | y |
---|
[9570719] | 407 | EOT |
---|
[9f577259] | 408 | } |
---|
| 409 | |
---|