Solved

change default value of registry

Posted on 2008-10-14
8
1,014 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
 

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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now