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

x
?
Solved

change default value of registry

Posted on 2008-10-14
8
Medium Priority
?
1,085 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 500 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 500 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

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…
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 …
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Loops Section Overview

971 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