Solved

binary key

Posted on 2009-04-11
11
268 Views
Last Modified: 2012-05-06
vbs code to add /edit binary key.
0
Comment
Question by:Indarnav
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

756 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