Solved

change default value of registry

Posted on 2008-10-14
8
1,029 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 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