Code:
;SteelKix Function: WriteValue()
;
;Author:		Boforce
;
;contributors:	None
;
;Action:		Creates a new key, adds another value-name to an existing key (and assigns it a value)
;		or changes the value of an existing value-name
;
;Syntax:		WriteValue("Key","Value","Data","Type")
;
;Version:		1.0
;
;Date:		2009-09-23
;
;Date Revised:	2009-09-23
;
;Parameters	Key
;		Required.	Identifies the key containing the value
;
;		Value
;		Optional.	Identifies the value whose data you want to discover
;			When omitted the (Default) value is used
;
;		Data
;		Required.	The data to store as the value of the entry
;
;		Type
;		Required.	Identifies the data type of the entry. The following data types are supported:
;			REG_SZ
;			REG_EXPAND_SZ
;			REG_BINARY
;			REG_DWORD
;			REG_MULTI_SZ
;
;Remarks:		None
;
;Returns:		Returns 'Command completed successfully' when successfull else an exception message
;
;Dependencies:
; SteelKix version: 0.2
; Tested with Dot Net 3.5.30729.01
; 
;Example(s):	Add string value:
;		$rc = WriteValue('HKEY_CURRENT_USER\Test','My Value','Data added','REG_SZ')
;		? 'Result  : ' + $rc
;
;Comments : This has been successfully tested on Windows XP SP3 with DOT NET 3.5.30729.01. 
;Source:
Function WriteValue($wvKey,$wvValue,$wvData,$wvType)
Dim $Win32,$DatType,$Action

Imports $Win32 = Microsoft.Win32

Select
   Case $wvType = 'REG_SZ'
	$DatType = $Win32.RegistryValueKind.String
   Case $wvType = 'REG_EXPAND_SZ'
	$DatType = $Win32.RegistryValueKind.ExpandString
   Case $wvType = 'REG_BINARY'
	$DatType = $Win32.RegistryValueKind.Binary
   Case $wvType = 'REG_DWORD'
	$DatType = $Win32.RegistryValueKind.DWord
   Case $wvType = 'REG_MULTI_SZ'
	$DatType = $Win32.RegistryValueKind.MultiString
   Case $wvType = 'REG_QWORD'
	$DatType = $Win32.RegistryValueKind.QWord
   Case $wvType = 'REG_UNKNOWN'
	$DatType = $Win32.RegistryValueKind.Unknown
EndSelect

Try
   $Action = $Win32.Registry.SetValue($wvKey,$wvValue,$wvData,$DatType)
EndTry
Catch
   $exc
EndCatch

If $exc
   $WriteValue = $exc.Message
Else
   $WriteValue = 'Command completed successfully'
EndIf
EndFunction