Solved

change default value of registry

Posted on 2008-10-14
8
1,023 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
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…
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…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

895 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

13 Experts available now in Live!

Get 1:1 Help Now