Sign in to follow this  
Followers 0
autoitNOW

RegRead for reading "value data"

9 posts in this topic

#1 ·  Posted (edited)

Hi,

I want to add the "value data" argument to RegRead and not just the "value name". The help example only shows "value name". What also seems weird is that you can put "value data" in arguments for RegWrite.

How do you get RegRead to do a if "value data" exist type of argument?

Help example- RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir")

But want for RegRead to do-

("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir");value name, "C:\Program Files" ;value data

RegRead ( "keyname", "valuename" )

RegRead reads back the value data, but I want to check if the a certain value data exists.

would like to see RegRead ("keyname", "valuename", "valuedata") or something that could do If Regkey exits...

Thanks in advance

Edited by autoitNOW

An ADVOCATE for AutoIT

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

it does what you want it to do... I guess the helpfile's a little confusing to you? I can understand, but look at the example there again:

$var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir")
MsgBox(4096, "Program files are in:", $var)

but, right in the parameters table, it explains what it means by valuename, that it's the value to read...

The more I think about it, the more it does seem a bit poorly worded, how could it be said better?

RegRead ( "keyname" , "valuename" )

keyname = the registry key to read

valuename = the value name to read data from.

would that slight change make it better? In regedit they're called value name and value data, so I think it'd be best to stick with those names, even if it's a little confusing?

I don't know... it didn't mess me up when I went to use it, but I can see how the wording could be better...

Edited by emmanuel

"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Yeah, I phrased that wrong. I wanted something more like to check if this regkey value data exist "C:\Program Files" than do... whatever.... As oppose to reading back to me what the reg value data is in a message box or giving me an error message that no value data exist.

For instance I might want to do X if the regkey value data is "C:\Program Files", but I want to do something else if the regkey value data is "X:\Program Files"

Thanks...

Edited by autoitNOW

An ADVOCATE for AutoIT

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

The more I think about it, the more it does seem a bit poorly worded, how could it be said better?

RegRead ( "keyname" , "valuename" )

keyname = the registry key to read

valuename = the value name to read data from.

would that slight change make it better?  In regedit they're called value name and value data, so I think it'd be best to stick with those names, even if it's a little confusing?

I don't know... it didn't mess me up when I went to use it, but I can see how the wording could be better...

keyname = the registry key to read

valuename = the value name that the value data will be read from

Return Value

Success: Returns the requested valuedata...

Failure: Returns numeric 1 and sets the @error flag:

1 if unable to open requested key

-1 if unable to open requested value

-2 if value type not supported

Edited by autoitNOW

An ADVOCATE for AutoIT

Share this post


Link to post
Share on other sites

Yeah, I phrased that wrong.  I wanted something more like to check if this regkey value data exist "C:\Program Files" than do... whatever.... As oppose to reading back to me what the reg value data is in a message box or giving me an error message that no value data exist.

For instance I might want to do X if the regkey value data is "C:\Program Files", but I want to do something else if the regkey value data is "X:\Program Files"

Thanks...

so do a little if then statement?

$var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir")
if $var = "c:\program files" then
  ;do something
elseif $var = "x:\program files" then
  ;do something else
elseif $var = 1 then
  ;do something else entirely
endif

something like that? at that point, a Select ... Case ... EndSelect might make more sense, just depends on how many options you're shooting for... also might want to capture the @error return to supply propper error handling..


"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

Yeah, that will defintely work. Thanks again... I also think that would be really great to put in the AutoIt help file as an example for noobs that face the "If regkey exist" type issue.


An ADVOCATE for AutoIT

Share this post


Link to post
Share on other sites

it's really just a case of your not knowing how the language works. to be blunt. if you'd read the Language Referance section of the helpfile you would have understood that you can check any value with if ... then ... elseif ... else. it's got nothing to do with checking if registry keys are or aern't there.


"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

My point was how to use AutoIt to check for regkey valuedata and to solve a problem. Hey, there are people that are new to Autoit and programming. Forgive me, if I do not know all the Autoit commands. I'm studying... But something that is obvious to you, may not be to a newbie or somebody that does not do this all the time, which is why people ask questions. I'm sure you asked a question or 2 or more... If you noticed there are a number of questions being asked. Well... thanks anyway, your help was greatly appreciated.

Edited by autoitNOW

An ADVOCATE for AutoIT

Share this post


Link to post
Share on other sites

it wasn't meant to be an insult, just a suggestion.


"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0