VBScript: Write Registry Binary Value

Write a string or a dword value in the registry is pretty easy but sometimes you need to write a binary value and it become more difficult....

The following example show how to set the Automatic Update Service Recovery Action to restart after 1 minute from the failure.

const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath = "SYSTEM\CurrentControlSet\Services\wuauserv"
strComputer = "."
iValues = Array(&H00,&H00,&H00,&H00,&H00,&H00,

&H00,&H65,&H00,&H01,&H00,&H00, &H00,&H60,&Hea,&H00,&H00,
&H00,&H00,&H00,&H00,&H00,&H00,&H00,&H00, &H00,&H00,&H00,
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"
& strComputer & "\root\default:StdRegProv")

BinaryValueName = "FailureActions"
oReg.SetBinaryValue HKEY_LOCAL_MACHINE,strKeyPath, BinaryValueName,iValues


About author

Vittorio Pavesi


  1. Anonymous
    8:40 AM

    Thank you!

  2. Anonymous
    10:40 AM

    Sorry but this dont work, cause max array size is 25 simbols..

Post a Comment