Docfxit Posted January 19, 2010 Share Posted January 19, 2010 (edited) I'm getting 2 errors with this script: 1 Opt("WinWaitDelay", 100) 2 Opt("WinTitleMatchMode", 4) 3 Opt("WinDetectHiddenText", 1) 4 Opt("MouseCoordMode", 0) 5 6 AutoItSetOption("TrayIconDebug", 1) ;0-off 7 8 If _OSVersion() = "Win7" Then 9 ProgramFiles = "C:\Programs\" 10 Else 11 ProgramFiles = "C:\Program Files\" 12 EndIf 13 Exit 14 15 Func _OSVersion() 16 Local $OS_Version, $servicepack_version 17 $OS_Version = StringStripWS(StringRegExpReplace(@OSVersion, "(WIN_)|(Microsoft )|(Windows )|(\(TM\))|( Ultimate)", ""), 8) 18 $OS_Version = StringRegExpReplace(StringRegExpReplace($OS_Version, '2008', 'Win7'), 'VISTA', 'Vista') 19 If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", 'CurrentBuildNumber') > 7000 Then $OS_Version = 'Win7' 20 $servicepack_version = StringReplace(@OSServicePack, "Service Pack ", "SP") 21 If @error = -1 Then $servicepack_version = "" 22 23 ConsoleWrite($OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '') & @CRLF) 24 Return $OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '') 25 EndFunc ;==>_OSVersion The errors are: OSVersion.au3(9,15) : ERROR: syntax error ProgramFiles = ~~~~~~~~~~~~~^ OSVersion.au3(8,15) : ERROR: _OSVersion(): undefined function. If _OSVersion() ~~~~~~~~~~~~~~^ I can't see what I am doing wrong. Thanks, Docfxit Edited January 19, 2010 by docfxit Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 19, 2010 Moderators Share Posted January 19, 2010 docfxit,In AutoIt all variables must begin with $ - because that is how Jon wrote the interpreter! So use $ProgramFiles instead.I do not get the second error and the syntax looks fine to me.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Mat Posted January 19, 2010 Share Posted January 19, 2010 (edited) I think (Though I have not used Win7) that you are doing a similar thing to the built in "@ProgramFilesDir" macro. If you use that instead then it will find it for you (and will be a lot more accurate). Local $ProgramFiles = @ProgramFilesDir or just use the macro directly. Mat Edit: Melba, the second error is because of the first, it's one of the odd quirks of Au3Check. Edited January 19, 2010 by Mat AutoIt Project Listing Link to comment Share on other sites More sharing options...
whim Posted January 19, 2010 Share Posted January 19, 2010 If the only use of _OSversion() is to 'serve' the If ...Else then you can save quite a bit of code by just using the @ProgramFilesDir macro, with the added advantage that the code will also run on installs that are not on the C: drive AFAIK it will also auto-adapt to the different paths on x86 and x64 hth, whim Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 19, 2010 Moderators Share Posted January 19, 2010 Mat and whim, You learn something everyday - thanks for that. m23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Docfxit Posted January 19, 2010 Author Share Posted January 19, 2010 Thank you all for the help. When I use @ProgramFilesDir It gives me C:\Program Files That is exactly what I want to use in XP. In Windows Seven the folder C:\Program Files is special and programs are not allowed to write to it unless they have administrator authority. It's easier for me to install programs into a folder I create called C:\Programs. Then I don't have to figure out how to give each program administrator authority. Thanks, Docfxit Link to comment Share on other sites More sharing options...
Mat Posted January 19, 2010 Share Posted January 19, 2010 Ah... Now you're getting into the difference between what a coder should do and what's easiest to do. This thread makes interesting reading on the subject. AutoIt Project Listing Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 19, 2010 Moderators Share Posted January 19, 2010 docfxit,I second Mat's comments. If you are writing for Vista/Win 7 then you must take UAC into account. The thread he pointed you to is well worth reading.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Docfxit Posted January 19, 2010 Author Share Posted January 19, 2010 Ah... Now you're getting into the difference between what a coder should do and what's easiest to do. This thread makes interesting reading on the subject.If I'm writing an application I can easily separate programs into C:\Programs Files and data into data folders.I'm using this code to install programs. Some of the programs have been updated to Win seven and some haven't. I can't force companies to update their software so they comply with Microsoft's new security measures.I have to find ways to use the old software on the new OS's.If anyone know of a better way to do it I'd be happy to entertain the idea.Thank you,Docfxit Link to comment Share on other sites More sharing options...
Mat Posted January 19, 2010 Share Posted January 19, 2010 I second Mat's comments. If you are writing for Vista/Win 7 then you must take UAC into account. The thread he pointed you to is well worth reading.I have just found out something I never knew before... A program requires permission under UAC to write to HKLM, but can write to HKCU. this completely messes up my old idea of "HKEY_LOCAL_MACHINE\SOFTWARE\%Author%\%AppName%\". Now heres the interesting bit. When the installer runs, it *should* write values referring to the install in that key. Settings should then be stored in "HKEY_CURRENT_USER\Software\%Author%\%AppName%\". Looks like the AutoIt devs know what they are doing thankfully, but this is news to me, so my old progs that store settings in the registry are probably wrong AutoIt Project Listing 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