GEOSoft Posted December 12, 2003 Share Posted December 12, 2003 I am starting to convert some AutoIt 2 scripts to Auto it 3 and I am running into problems. If I use the following example it works. $VN=RegRead ( "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion", "versionnumber" ) MsgBox(4096,"" , "The Version Number is: "&$VN) Exit I want to declare HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion as a variable (RegPath), but I can't get it to work right. I have to use that string several times in the script so hard-coding the path is not the greatest answer. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Administrators Jon Posted December 12, 2003 Administrators Share Posted December 12, 2003 $mykey = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion" $VN = RegRead ($mykey, "versionnumber") Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Administrators Jon Posted December 12, 2003 Administrators Share Posted December 12, 2003 Oh, and they are not Env variables in v3 they are internal AutoIt variables. And I wouldn't go nuts converting large script, the syntax of v3 is ever changable until I release. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
GEOSoft Posted December 12, 2003 Author Share Posted December 12, 2003 Thanks Jon. That worked and while I was waiting I tried something else that also worked. AutoItSetOption("ExpandEnvStrings", 1) EnvSet ("Key","HKEY_LOCAL_MACHINE\") EnvSet ( "RP", "Software\Microsoft\Windows\CurrentVersion" ) $VN=RegRead ( "%Key%%RP%", "versionnumber" ) MsgBox(4096,"" , "The Version Number is: "&$VN) Exit What are the pro's and con's of the two methods? Also is it still \n for a new line in a message box? I can understand that you will be making more changes yet but this at least gives me the practice with the new code and gives me a head start on the files. This particular script is quite long and has many things to convert. The reason I chose it for a starter is because it is the script that I needed a method to set defaults in the InputBoxes and ver.3 allows that. :-) Now I can get on to the part that converts that version number to a string that actually shows the Windows version being used. At one point (maybe in ver.2) I came across the code to return the version but it did not handle sub-versions. Windows 98SE was still reported as Windows 98. I seem to recall having the same problem with XP Pro and XP Home. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
scriptkitty Posted December 12, 2003 Share Posted December 12, 2003 (edited) AutoItSetOption("ExpandEnvStrings", 1) EnvSet ("Key","HKEY_LOCAL_MACHINE\") EnvSet ( "RP", "Software\Microsoft\Windows\CurrentVersion" ) $VN=RegRead ( "%Key%%RP%", "versionnumber" ) MsgBox(4096,"" , "The Version Number is: "&$VN) ExitEnvSet seems to be just extra work to me This should work as well $Key="HKEY_LOCAL_MACHINE\" $RP="Software\Microsoft\Windows\CurrentVersion" $VN=RegRead ( $Key&$RP, "versionnumber" ) MsgBox(4096,"" , "The Version Number is: "&$VN) Exit Oh, I use the Line feed @LF as in: MsgBox(4096,"" , "The Version Number is: "&$VN & @LF & "Next line") You can also use CHR(10) or CHR(13) MsgBox(4096,"" , "The Version Number is: "&$VN & chr(10) & "Next line") Edited December 12, 2003 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
Administrators Jon Posted December 12, 2003 Administrators Share Posted December 12, 2003 Don't use Env variables at all. Unless you want to retrieve "comspec" or "profile" or something like that. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
GEOSoft Posted December 12, 2003 Author Share Posted December 12, 2003 Thanks scriptkitty, that worked just fine. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" 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