Jump to content

Recommended Posts

Posted (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 by docfxit
  • Moderators
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted (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 by Mat
Posted

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

  • Moderators
Posted

Mat and whim,

You learn something everyday - thanks for that. :D

m23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

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

  • Moderators
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

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

Posted

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 :D

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...