Solved

binary key

Posted on 2009-04-11
11
240 Views
Last Modified: 2012-05-06
vbs code to add /edit binary key.
0
Comment
Question by:Indarnav
  • 5
  • 3
  • 3
11 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 24124525
http://vittoriop77.blogspot.com/2005/01/vbscript-write-registry-binary-value.html gives a decent example:
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 

Open in new window

0
 

Author Comment

by:Indarnav
ID: 24124552
syntax error line 4
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 24124555
The array lines all need to be on one line:
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 

Open in new window

0
 

Author Comment

by:Indarnav
ID: 24124563
still same error
0
 

Author Comment

by:Indarnav
ID: 24124599
will ur code change default value of failureactions?
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:Indarnav
ID: 24124662
it will be help u...

i want following key to be edited with following value..

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer]
"ShellState"=hex:24,00,00,00,33,08,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
  01,00,00,00,12,00,00,00,00,00,00,00,22,00,00,00

now give vbs code for this.
0
 
LVL 39

Accepted Solution

by:
abel earned 500 total points
ID: 24125368
This seems to be the same question as this one, where I answered with a working script. Can you refer to that question to see if that works for you?

http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24315561.html#24125186
0
 
LVL 39

Expert Comment

by:abel
ID: 24125389
> still same error

the error you receive for sirbounty's code is because of a cut-n-paste error.  He probably posted

   Array(&H00,&H00,&H00,&H00,...

but it somehow got messed up on the EE site as a result of encoding problems into what you see:

  Array(&H00,&H00,&H00,&H00,...

in other words: remove the "&" for "&".

@sirbounty:> The array lines all need to be on one line:

not really. But if you split lines in VBS, you need to end each line with a space and an underscore. See my previous post + solution for how I did that, to keep the code readable.

-- Abel --
0
 
LVL 39

Expert Comment

by:abel
ID: 24125400
> will ur code change default value of failureactions?

the code of sirbounty uses a different replacement string as you may have seen by now, it starts out with different values.  He showed the code as an example of how you can do it, I think.

Use your own string (amended to the &H-style for VBS) or check my solution, which also uses your string, correctly amended.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 24125484
@abel - the site I copied this from didn't have the continuation characters present in their, so that is why I made that statement...
0
 

Author Comment

by:Indarnav
ID: 24125578
got solution form abel's link. it is working fine.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now