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,&H00,&H00,&H00,&H00,&H00,&H03,&H00,&H00,&H00,&H53,
&H00,&H65,&H00,&H01,&H00,&H00, &H00,&H60,&Hea,&H00,&H00,
&H00,&H00,&H00,&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

Share on Google Plus

About Vittorio Pavesi

    Blogger Comment
    Facebook Comment

2 comments:

Anonymous said...

Thank you!

Anonymous said...

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