ankur3020
asked on
check reg_sz
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.
{ 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.
ASKER
still getting same error
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
You trying to write to path "HKEY_LOCAL_MACHINE\HKEY_C LASSES_use r\software " Reg ValueName "stop" and Value "7BA4C7450-9E86".
Are you sere that this path exists in toy registry?
Are you sere that this path exists in toy registry?
ASKER
no, by mistake i added additional path.
find the correct code.
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
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
you must define it before you can use it
HIVE ID for HKEY_CURRENT_USER is &H80000001
ASKER
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.
pls guide how to change default key value of any registry.
ASKER
pls guide now i m using attached code, but it is not working.
Set oWS = CreateObject("wscript.shel l")
sKeyPath = "AllFilesystemObjects\shel lex\Contex tMenuHandl ers\Send To\"
oWS.RegWrite "HKCR\" & sKeyPath, 0, "REG_SZ"
it is not changing value of default key.
Set oWS = CreateObject("wscript.shel
sKeyPath = "AllFilesystemObjects\shel
oWS.RegWrite "HKCR\" & sKeyPath, 0, "REG_SZ"
it is not changing value of default key.
ASKER
i able to do what i tried. thanks. for your support
ASKER
perfect answer
If value <> '7BA4C7450-9E86' Then