Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

binary key

Posted on 2009-04-11
11
Medium Priority
?
283 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
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!

 

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

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…
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month11 days, 10 hours left to enroll

916 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