?
Solved

check reg_sz

Posted on 2008-10-10
11
Medium Priority
?
482 Views
Last Modified: 2012-05-05
i am trying to check whether

{ 7BA4C7450-9E86} value exists in registry or not and if not i want to add. but when i am using if statement it is giving error , pls tell how to write if statement for this value.

i am typing like as follows.

If value <> 7BA4C7450-9E86 Then

and error i got is "then required".
should i need to quote value i m checking or some other thing.

0
Comment
Question by:ankur3020
[X]
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
  • 7
  • 3
11 Comments
 
LVL 16

Expert Comment

by:brad2575
ID: 22689575
you may need quotes around the value
If value <> '7BA4C7450-9E86' Then
0
 

Author Comment

by:ankur3020
ID: 22691872
still getting same error
0
 
LVL 5

Accepted Solution

by:
si_shamil earned 200 total points
ID: 22698833
try to use double quotes, single quotes is comments in vbscript

If value <> "7BA4C7450-9E86" Then
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:ankur3020
ID: 22703419
nothing happened.pls check attached code to find error. now even i removed if statement still not able to add below string.
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set StdOut = WScript.StdOut
 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ 
strComputer & "\root\default:StdRegProv")
 
strKeyPath = "HKEY_CLASSES_user\software"
strValueName = "stop"
strValue = "7BA4C7450-9E86"
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

Open in new window

0
 
LVL 5

Expert Comment

by:si_shamil
ID: 22704444
You trying to write to path "HKEY_LOCAL_MACHINE\HKEY_CLASSES_user\software" Reg ValueName "stop" and Value "7BA4C7450-9E86".

Are you sere that this path exists in toy registry?
0
 

Author Comment

by:ankur3020
ID: 22708095
no, by mistake i added additional path.

find the correct code.


const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set StdOut = WScript.StdOut
 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ 
strComputer & "\root\default:StdRegProv")
 
strKeyPath = "software\myvb"
strValueName = "stop"
strValue = "7BA4C7450-9E86"
oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue

Open in new window

0
 
LVL 5

Expert Comment

by:si_shamil
ID: 22708278
In the script above you have "HKEY_CURRENT_USER" variable/constant that is not defined.

you must define it before you can use it
HIVE ID for HKEY_CURRENT_USER is &H80000001
0
 

Author Comment

by:ankur3020
ID: 22713493
u r ok. but real problem now i got and it is i am trying to change default key. which is not changed by my code.

pls guide how to change default key value of any registry.
0
 

Author Comment

by:ankur3020
ID: 22721742
pls guide now i m using attached code, but it is not working.

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

it is not changing value of default key.
0
 

Author Comment

by:ankur3020
ID: 22723448
i able to do what i tried. thanks. for your support
0
 

Author Closing Comment

by:ankur3020
ID: 31505107
perfect answer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

801 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