Solved

binary key

Posted on 2009-04-11
11
278 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

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

729 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