microbious Posted April 30, 2009 Share Posted April 30, 2009 (edited) $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 April 30, 2009 by stoopid Link to comment Share on other sites More sharing options...
Juvigy Posted April 30, 2009 Share Posted April 30, 2009 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 Link to comment Share on other sites More sharing options...
bo8ster Posted April 30, 2009 Share Posted April 30, 2009 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] Link to comment Share on other sites More sharing options...
microbious Posted April 30, 2009 Author Share Posted April 30, 2009 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. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 30, 2009 Developers Share Posted April 30, 2009 (edited) 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 April 30, 2009 by Jos SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
microbious Posted May 1, 2009 Author Share Posted May 1, 2009 (edited) 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 masgboxso 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.comhere http://adrenalineparty.com/savedfixers.shtmlAt 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 Edited May 1, 2009 by stoopid Link to comment Share on other sites More sharing options...
bo8ster Posted May 1, 2009 Share Posted May 1, 2009 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] Link to comment Share on other sites More sharing options...
microbious Posted May 1, 2009 Author Share Posted May 1, 2009 Nah i didnt even think of any offense. And no, the question remains unanswered. Link to comment Share on other sites More sharing options...
microbious Posted May 1, 2009 Author Share Posted May 1, 2009 (edited) 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 May 1, 2009 by stoopid Link to comment Share on other sites More sharing options...
BrettF Posted May 1, 2009 Share Posted May 1, 2009 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. Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
microbious Posted May 1, 2009 Author Share Posted May 1, 2009 (edited) 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.txttest_delete.txt Edited May 1, 2009 by stoopid Link to comment Share on other sites More sharing options...
microbious Posted May 1, 2009 Author Share Posted May 1, 2009 (edited) 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") EndIfThis works.But i want to use RegRead as $variation, something likeIf 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 thisAm talking to my self here, no wonder i picked this nick Edited May 1, 2009 by stoopid Link to comment Share on other sites More sharing options...
DCCD Posted May 1, 2009 Share Posted May 1, 2009 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) [u][font=Arial Black]M[/font]y Blog, AVSS Parts[/u][font=Arial Black]Else[/font][font=Arial Black]L[/font]ibya Linux Users Group Link to comment Share on other sites More sharing options...
microbious Posted May 1, 2009 Author Share Posted May 1, 2009 (edited) 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 May 1, 2009 by stoopid Link to comment Share on other sites More sharing options...
BrettF Posted May 1, 2009 Share Posted May 1, 2009 (edited) 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) EndIfReally, please look closer at the code posted, and the helpfile.Cheers,BrettEDIT: http://www.autoitscript.com/forum/index.php?showtopic=260 Edited May 1, 2009 by BrettF Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
microbious Posted May 1, 2009 Author Share Posted May 1, 2009 (edited) 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 May 2, 2009 by stoopid Link to comment Share on other sites More sharing options...
BrettF Posted May 2, 2009 Share Posted May 2, 2009 Do you specifically need the .reg file? There is RegWrite... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
microbious Posted May 2, 2009 Author Share Posted May 2, 2009 yes i need to export whole key including subkeys and all values into 1 reg file Link to comment Share on other sites More sharing options...
blakel Posted May 2, 2009 Share Posted May 2, 2009 Run(@ComSpec & 'dir "c:\document and settings"') note the nested quotes Link to comment Share on other sites More sharing options...
microbious Posted May 2, 2009 Author Share Posted May 2, 2009 (edited) 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 May 2, 2009 by stoopid Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now