Sign in to follow this  
Followers 0
PartyPooper

@OSVersion problem

9 posts in this topic

I'm using XP and only want to allow my script to run on Windows 2000, 2003 or XP machines. Can someone point out why the first script works and the second one doesn't?

If @OSVersion = "WIN_2000" Or @OSVersion = "WIN_2003" Or @OSVersion = "WIN_XP" Then
    MsgBox(0,'','continue script')
Else
    MsgBox(0,'','stop script')
    Exit
EndIf

If @OSVersion <> "WIN_2000" Or @OSVersion <> "WIN_2003" Or @OSVersion <> "WIN_XP" Then
    MsgBox(0,'','stop script')
    Exit
EndIf

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Um, it works on mine :P, at least I get the popup if that's what your trying to accomplish.

Edit:

Try this to debug:

If @OSVersion <> "WIN_2000" Then MsgBox(0,'1',"WIN_2000 Does Not Exist")
If @OSVersion <> "WIN_2003" Then MsgBox(0,'2',"WIN_2003 Does Not Exist")  
If @OSVersion <> "WIN_XP" Then MsgBox(0,'3',"WIN_XP Does Not Exist")
Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

umm this might help

If @OSVersion <> "WIN_2000" AND @OSVersion <> "WIN_2003" AND @OSVersion <> "WIN_XP" Then
    MsgBox(0,'','stop script')
    Exit
EndIf

--hope this helps

Edited by cdkid

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites

If @OSVersion <> "WIN_2000" Or @OSVersion <> "WIN_2003" Or @OSVersion <> "WIN_XP" Then
    MsgBox(0,'','stop script')
    Exit
EndIf
I'm on my Linux laptop right now, so I can't try it without a reboot, but the logic looks broke to me. When you use IF with OR statement, you have satisfied the IF condition as soon as any one of the OR conditions is true.

Assume @OSVersion is "Win_XP".

The first test is: "Win_XP" <> "Win_2000", which is true, the IF condition is satisfied, and you stop the script. Change those OR's to AND's and I think you get what you wanted:

If @OSVersion <> "WIN_2000" And @OSVersion <> "WIN_2003" And @OSVersion <> "WIN_XP" Then
    MsgBox(0,'','stop script')
    Exit
EndIf

This is a three input and gate, all three ones in to get the one out. All three compares must be satisfied to trigger the THEN condition. Of course I can't try it right now so... :P


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Um, it works on mine :P, at least I get the popup if that's what your trying to accomplish.

Edit:

Try this to debug:

If @OSVersion <> "WIN_2000" Then MsgBox(0,'1',"WIN_2000 Does Not Exist")
If @OSVersion <> "WIN_2003" Then MsgBox(0,'2',"WIN_2003 Does Not Exist")  
If @OSVersion <> "WIN_XP" Then MsgBox(0,'3',"WIN_XP Does Not Exist")

Works for you? Strange.

When I run them one after the other, I get a 'continue script' box followed by a 'stop script' box. I was expecting and should just get the 'continue script' box from the first script if I'm using Windows XP, 2000 or 2003. Try the following code.

If @OSVersion = "WIN_2000" Or @OSVersion = "WIN_2003" Or @OSVersion = "WIN_XP" Then
    MsgBox(0,'','Win XP, 2000 or 2003 detected correctly')
Else
    MsgBox(0,'','stop script')
    Exit
EndIf
If @OSVersion <> "WIN_2000" Or @OSVersion <> "WIN_2003" Or @OSVersion <> "WIN_XP" Then
    MsgBox(0,'','should not appear if using Win XP, 2000 or 2003')
    Exit
EndIf

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

umm this might help

If @OSVersion <> "WIN_2000" AND @OSVersion <> "WIN_2003" AND @OSVersion <> "WIN_XP" Then
    MsgBox(0,'','stop script')
    Exit
EndIf

--hope this helps

ok, i just tested it using OR and it didnt work... im on XP and it gave me the messagebox then i tried it with AND... it worked just fine :P i thought that'd work Edited by cdkid

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Yeah, its the OR operator - should be an AND. Don't know why but it always trips me up when I use <> and OR in conjunction with an IF statement.

Thanks all.

Edited by PartyPooper

Share this post


Link to post
Share on other sites

If @OSVersion = "WIN_2000" Or @OSVersion = "WIN_2003" Or @OSVersion = "WIN_XP" Then
Why not use @OSBuild and use one statement, e.g. (don't know the build number of Win2K):

if @osbuild < 2200 then
rest of code...

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

Because I'm not sure about the build numbers either

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  
Followers 0