| |

How do I write to the registry via Transact-SQL?
Answer:
You can use the xp_regwrite undocumented extended stored procedure
to write to the registry via Transact-SQL.
This is the syntax of the xp_regwrite:
EXECUTE xp_regwrite [@rootkey=]'rootkey',
[@key=]'key',
[@value_name=]'value_name',
[@type=]'type',
[@value=]'value'
|
For example, to write the variable 'Test' to the 'TestValue' value,
key 'SOFTWARE\Test', 'HKEY_LOCAL_MACHINE', run:
EXEC master..xp_regwrite
@rootkey='HKEY_LOCAL_MACHINE',
@key='SOFTWARE\Test',
@value_name='TestValue',
@type='REG_SZ',
@value='Test'
|
See this FAQ question:
How do I read from the registry via Transact-SQL?
See this article to get more useful undocumented extended stored procedures:
Useful undocumented extended stored procedures
|
|