Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
The Registry Provider s SetStringValue and SetDWORDValue methods enable you to create string and DWORD-valued registry entries. Each of the methods accepts the same four parameters: a constant corresponding to the subtree in which the entry will be created, the path to the subkey in which the entry will be created, the name of the entry, and the value of the entry.
Note that the subkey must already exist. If the subkey does not exist, the script cannot create it for you. Because no location is available for the entry, the script will fail.
Be careful to use the method that corresponds to the data type of the value you want to create. If you want to create an entry with the DWORD value 8 and you mistakenly use the SetStringValue method and pass it the value 8, the method will interpret the 8 as the string "8" without warning you. This could incorrectly configure the registration, and lead to any number of problems..
Listing 16.9 contains a script that creates two entries in the System Admin Scripting Guide subkey, one having a string value and the other a DWORD value, in the subkey created by the script in Listing 16.8. Before running this script, run the script in Listing 16.8 to create the subkey SOFTWARE\System Admin Scripting Guide.
To carry out this task, the script must perform the following steps:
Listing 16.9 Creating Registry String-valued and DWORD-valued Entries
|
|
Figure 16.5 shows the newly created string and DWORD-valued entries in a registry editor.
Figure 16.5 Viewing Newly Created Entries Using a Registry Editor
Viewing Newly Created Entries Using a Registry Editor
![]() | « Previous | Next » |