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
Solved

change default value of registry

Posted on 2008-10-14
8
1,034 Views
Last Modified: 2012-05-05
how to change value of default registry key.

i.e. suppose u open registry hkey_classes_root/qyplayer/default

now i want to change value of this default key created wtih qtplayer.

pls provide vbs code.
0
Comment
Question by:ankur3020
  • 4
  • 4
8 Comments
 
LVL 7

Assisted Solution

by:Hubasan
Hubasan earned 125 total points
ID: 22715137
You can use following script to change the default value of any registry key:

Bare in mind that following rules apply here:

1) sKeyPath variable points to a registry key that has to already be created
2) oWS.RegWrite command users the following syntax:

oWS.RegWrite( strName, anyvalue [,strType])

The RegWrite cannot write to REG_MULTI_SZ strings and is limited to writing only four bytes or one DWORD in REG_BINARY.

Script below will add a zero to the Default value of HKLM\SOFTWARE\Script Testing\ key if one exists on your machine.

Set oWS = CreateObject("wscript.shell")
 
sKeyPath = "SOFTWARE\Script Testing\"
 
oWS.RegWrite "HKLM\" & sKeyPath, 0, "REG_SZ"

Open in new window

0
 

Author Comment

by:ankur3020
ID: 22717549
i am using following code, but nothing happened. pls check . the default key is already existing and i want to change value of this default key.

in the following code there is a default key and it has some value {....} and i want to change that value with 0.

pls guide
Set oWS = CreateObject("wscript.shell")
 
sKeyPath = "AllFilesystemObjects\shellex\ContextMenuHandlers\Send To"
 
oWS.RegWrite "HKEY_CLASSES_ROOT\" & sKeyPath, 0, "REG_SZ"

Open in new window

0
 
LVL 7

Accepted Solution

by:
Hubasan earned 125 total points
ID: 22717622
You have 2 problems in your code:
1) your sKeyPath is not correct, you have to put "\" at the end of the path to tell the registry that you are changing the value under Send To key.
2) HKEY_CLASSES_ROOT is not a valid name for the Registry Hive of Classes root. You have to use HKCR.

I have changed your code below and it should work now.
Set oWS = CreateObject("wscript.shell")
 
sKeyPath = "AllFilesystemObjects\shellex\ContextMenuHandlers\Send To\"
 
oWS.RegWrite "HKCR\" & sKeyPath, 0, "REG_SZ"

Open in new window

0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:ankur3020
ID: 22721716
i used ur code but no results. the code i used is attached.pls guide.
Set oWS = CreateObject("wscript.shell")
 
sKeyPath = "AllFilesystemObjects\shellex\ContextMenuHandlers\Send To\"
 
oWS.RegWrite "HKCR\" & sKeyPath, 0, "REG_SZ"

Open in new window

0
 
LVL 7

Expert Comment

by:Hubasan
ID: 22721872
Hi ankur3020,

The code I posted has been tested and it works as expected. I just re-tested it again.

The script will overwrite the Default value's data from "{7BA4C740-9E81-11CF-99D3-00AA004AE837}" ( this is on Windows XP SP2) to value data "0", which effectively removes the Send To right-click context menu from your PC.

What exactly are you trying to do and what do you mean when you say "no results".
Give me as much details as possible about what are you trying to do and maybe I can help you.
0
 

Author Comment

by:ankur3020
ID: 22723410
yes r u right, it worked now. thanks dear.
0
 

Author Closing Comment

by:ankur3020
ID: 31505940
thanks for ur guidance.
0
 
LVL 7

Expert Comment

by:Hubasan
ID: 22723587
You are welcome :-)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

856 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