Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

binary key

Posted on 2009-04-11
11
Medium Priority
?
282 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

705 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