Jump to content
Sign in to follow this  
microbious

regreed help

Recommended Posts

microbious

$var = RegRead("HKEY_CURRENT_USER\Software\somekey", "")
If  $var > ?  Then 
    MsgBox(4096,"Information", "Registry exist")
Else
    MsgBox(4096, "Information", "Registry does not exist.")
    Exit

Someone help me to figure this out.

When key does not exist, than what is the output value ?

Look at

If  $var > ?  Then
What do i put instead of "?" ?

I want it to see message"Registry exist" if it exist and next message if it doesn't.

Please help, this is my first day trying to learn this language (any language for that matter)

Thanks in advance.

Edited by stoopid

Share this post


Link to post
Share on other sites
Juvigy

From the help file:

Success: Returns the requested registry value. @EXTENDED is set to the type of the value $REG_... . These types are defined in the "Constants.au3" include file. 
[b]Failure: Returns ""[/b] and sets the @error flag: 
 1 if unable to open requested key 
 2 if unable to open requested main key 
 3 if unable to remote connect to the registry 
 -1 if unable to open requested value 
 -2 if value type not supported

Share this post


Link to post
Share on other sites
bo8ster

The search feature is great - I found http://www.autoitscript.com/forum/index.php?showtopic=93941. You will find many other examples on the forum.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites
microbious

with all do respect, wouldn't it be easier just to tell me what to replace the question mark with ?

I looked into help file but its not very clear caz i am new at this.

Share this post


Link to post
Share on other sites
Jos

with all do respect, wouldn't it be easier just to tell me what to replace the question mark with ?

I looked into help file but its not very clear caz i am new at this.

With all due respect back: You need to replace your If totally and test the @error for the correct value as indicated and you should be able to do that yourself. ^_^ Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
microbious

Thanks.

I wasnt sure if "IF" was a good idea or not (im still learning).

I assumed that when regreed gets no key to reed than i could go with IF &var = 0 (i think 0 stands for nothing ?)

then masgbox

so it looks like

$var = RegRead("HKEY_CURRENT_USER\Software\somekey", "")

If $var = 0 Then

MsgBox(4096,"Information", "Registry does not exist")

I dont see any other logical way to get to message box if key dont exist and go to another message box if key exist.

Example command would do the trick (if you could be so kind)

But please give me simple example as i just started to learn this thing.

What i am trying to accomplish here is i have made lots or backup utilities using CMD scripts.

Those CMD scripts would backup all registry/regiostratio/serialnumbers/license files and much more that one or another software outputs into your computer when used.

Those backups can later be restored with restore CMD script and software will be fully activated and 100% operational even if you formated WINDOWS drive and reinstalled OS.

Some guy was kind enough to host those files for me on www.adrenalineparty.com

here http://adrenalineparty.com/savedfixers.shtml

At this point i want to takes those backup utilities to the next level, with GUI buttons and options.

I tried C++ C# and they were to confusing for me so i thought i stuck to CMD forever until i found link to AUTOIT on SS64 DAMN i was happy this thing was free and its good too :D :D :)

;)^_^:(

Edited by stoopid

Share this post


Link to post
Share on other sites
bo8ster

with all do respect, wouldn't it be easier just to tell me what to replace the question mark with ?

I looked into help file but its not very clear caz i am new at this.

To be honest I don't know what should have been where the ? was. Since no one had responded to your post and I have seen many topics on the subject I thought I would try and lead you in the right direction. I was not referring to the help file, but suggesting you see how other people had done it. Some ppl post without searching the Example Scripts section where most of the best examples are.

I did not mean any offence. Good to see you got your answer.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites
microbious

Nah i didnt even think of any offense.

And no, the question remains unanswered.

Share this post


Link to post
Share on other sites
microbious

It seems to me that this is not going anywhere so im pretty sure i need to ask one more time and maybe this time i will make things clear.

I need example for RegRead that will try to read "HKEY_CURRENT_USER\Software\test".

If key exist, then pop a message saying so, or go to line or go to &var and continue command from there.

If key is not in the registry, then pop another message or go to another line or go to another &var and continue command from there.

How do i make that happened ?

example would be great ^_^

Edited by stoopid

Share this post


Link to post
Share on other sites
BrettF

Okay. Your name matches your level of intelligence...

Seriosuly Jos gave you the answer, you just didn't bother to apply it.

$key = "HKEY_CURRENT_USER\Software\test"

$read = RegRead ($key,"")

If @error Then
    MsgBox (0, "", "Key probably doesn't exist!")
Else
    MsgBox (0, "", "Key was read properly.  Value = " & @CRLF & $read)
EndIf

Cheers,

Brett.

Share this post


Link to post
Share on other sites
microbious

this script tells me that Key probably doesn't exist, but it does ^_^

Try these 2 attached reg files.

1 creates and one removes created test key

I made those to quickly test if it works or not.3

Make sure to rename txt to reg caz i cant upload regs for some reason

So anyway i was looking into help file and i think that what i need is to define the output value for regread, but where ?

when RegRead reads the key and its there, it returns as 1 right ?

So how can i use this return code other than with:

&var RegRead ("key","value")

If &var = 1 then

MsgBox (.,"","")

What am i doing wrong here ?

isn't 1 stands for return code ?

test_create.txt

test_delete.txt

Edited by stoopid

Share this post


Link to post
Share on other sites
microbious

Here is what i figured seems to work.

RegRead ( "HKEY_CURRENT_USER\Software\test", "" )
If @error=-1 Then
    MsgBox(4096,"Error", "yes")
Else
    MsgBox(4096, "Result", "no")
EndIf

This works.

But i want to use RegRead as $variation, something like

If variation error output was success (success defined by what, -1 ? weird but its only one that works so far) then something.

How can this be accomplished ?

It looks logical to me to use the following code as an example.

$var = RegRead ("key", "value") ;RegRead is a variation.

If $var @error=-1 Then ;so if variations error output was -1, the go do something.

but i get build error with this

Am talking to my self here, no wonder i picked this nick ^_^

Edited by stoopid

Share this post


Link to post
Share on other sites
DCCD

give it a try

#RequireAdmin
$RegRead1 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "MediaPath") ;Rename "MediaPath" to "Umm"
$RegRead2 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesPath")


If $RegRead1 = Not @error Then
    TrayTip("Key#1 Success...open requested key", $RegRead1, 10, 1)
Else
    TrayTip("Key#1 Failure open requested key...", "unable to open requested key.  ", 10, 3)
EndIf
Sleep(5000)

Share this post


Link to post
Share on other sites
microbious

in your code i changed

"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "MediaPath"

to

"HKEY_CURRENT_USER\Software\test", ""

Still no expected result.

Key is there but it wont read it.

To test it, i am using "test create.reg" and "test delete.reg" files

"test create.reg" has the following:

Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\test]

"test delete.reg" has the following:

Windows Registry Editor Version 5.00
[-HKEY_CURRENT_USER\Software\test]

So create creates the key, and delete removes it.

When created and your script executed, i get tray message:

unable to open requested key

When key is removed, i get same message.

Let me think of another way.

RegRead outputs Error code right ?

what is the Error code output If success ? Help file doesnt specify success code only failure code.

So once RegRead successfully reads the key

$var = RegRead (what ever)

what do i put on the second line to read this error code so i could use it as:

If $var error code = or > or < orsomething then

Help ? ^_^;):(

Edited by stoopid

Share this post


Link to post
Share on other sites
BrettF

I have no problem with this.

$key = "HKEY_CURRENT_USER\Software\test_12345"

$read = RegRead ($key, "")

If (@error = 1) OR (@ERROR = -1) Then
    MsgBox (0, "", "Key doesn't exist!" & @CRLF & "Creating it now, so run again to delete it")
    RegWrite ($key)
Else
    MsgBox (0, "", "Key was read properly.  Value = " & @CRLF & $read)
    RegDelete ($key)
EndIf

Really, please look closer at the code posted, and the helpfile.

Cheers,

Brett

EDIT: http://www.autoitscript.com/forum/index.php?showtopic=260

Edited by BrettF

Share this post


Link to post
Share on other sites
microbious

Need help to export registry which export directory has space on name.

as C:\ my folder\export file.reg

Here is what i tried

ShellExecute( "regedit.exe", "/E C:\Documents and Settings\Administrator\My Documents\file.reg HKEY_CURRENT_USER\test" )

Reg key will net be exported unless directory has no space in the name.

ShellExecute( "regedit.exe", "/E C:\file.reg HKEY_CURRENT_USER\test" )

this would work

Thanks in advance

Edited by stoopid

Share this post


Link to post
Share on other sites
BrettF
microbious

yes i need to export whole key including subkeys and all values into 1 reg file

Share this post


Link to post
Share on other sites
blakel

Run(@ComSpec & 'dir "c:\document and settings"')

note the nested quotes

Share this post


Link to post
Share on other sites
microbious

what ?

sorry i don understand what you mean.

where is regedit ? and why run ?

ShellExecute is the only one that works but i cant get it working because path has space in path name

Edited by stoopid

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  

×