rchamberlin Posted April 2, 2004 Share Posted April 2, 2004 I'm pretty new to Autoit, but I'm writing a script to do an automated install of a program. The problem is I only want it to install on Windows 2000/XP and not Windows NT. I did a search on these forums, but didn't really find anything. What I'd like to do is basically If Winver = NT Then Exit Else Run Script... Exit Any ideas? Thanks for any help. I would assume this has to have come up before. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 2, 2004 Developers Share Posted April 2, 2004 AutoIt3 has these Macros defined (Cut&Paste from the helpfile): @OSType Returns "WIN32_NT" for NT/2000/XP and returns "WIN32_WINDOWS" for 95/98/Me @OSVersion Returns one of the following: WIN_XP, WIN_2000, WIN_NT4, WIN_ME, WIN_98, WIN_95 @OSBuild Returns the OS build number. For example, Windows 2003 Server returns 3790 @OSServicePack Service pack info in the form of "Service Pack 3" or, for Windows 95, it may return "B" So in your code you can refer to them with something like: If @OSTYPE = "WIN32_NT" then ; run your pgm EndIF 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...
Valik Posted April 2, 2004 Share Posted April 2, 2004 Searching the helpfile would of been a better choice than the forum. Straight from the help file: @OSType Returns "WIN32_NT" for NT/2000/XP and returns "WIN32_WINDOWS" for 95/98/Me @OSVersion Returns one of the following: WIN_XP, WIN_2000, WIN_NT4, WIN_ME, WIN_98, WIN_95 @OSBuild Returns the OS build number. For example, Windows 2003 Server returns 3790 @OSServicePack Service pack info in the form of "Service Pack 3" or, for Windows 95, it may return "B" Link to comment Share on other sites More sharing options...
GrahamS Posted April 2, 2004 Share Posted April 2, 2004 So I'm not the only one to start an answer just to find out that somebody has beaten me to it GrahamS Link to comment Share on other sites More sharing options...
ZenKensei Posted April 3, 2004 Share Posted April 3, 2004 rchamberlin, If I understand your post correctly, you want to install ONLY to Windows 2000 or Windows XP? And specifically NOT to Windows NT 4.0? The following code should be of some help, I also added code to filter out the Windows 9x & ME Clients as well. $OS = @OSVersion $OSVer = @OSType If $OSVer <> 'Win32_NT' Then; Filters out Windows 9x & ME clients Exit EndIf If $OS = 'Win_NT' Then; Filters out Windows NT 4.0 MsgBox(0, "Operating System", "Incorrect Operating System - Windows XP or 2000 Required") Exit (0) EndIf MsgBox(0, "Operating System", "Running Windows 2000 or XP") I tested it quickly on my own XP machine and it seemed to work as expected. I hope it helps. Z/K Link to comment Share on other sites More sharing options...
jpm Posted April 3, 2004 Share Posted April 3, 2004 rchamberlin, If I understand your post correctly, you want to install ONLY to Windows 2000 or Windows XP? And specifically NOT to Windows NT 4.0? The following code should be of some help, I also added code to filter out the Windows 9x & ME Clients as well. $OS = @OSVersion $OSVer = @OSType If $OSVer <> 'Win32_NT' Then; Filters out Windows 9x & ME clients Exit EndIf If $OS = 'Win_NT' Then; Filters out Windows NT 4.0 MsgBox(0, "Operating System", "Incorrect Operating System - Windows XP or 2000 Required") Exit (0) EndIf MsgBox(0, "Operating System", "Running Windows 2000 or XP") I tested it quickly on my own XP machine and it seemed to work as expected. I hope it helps. Z/KIf $OS = 'Win_NT' Then; Filters out Windows NT 4.0should be If $OS = 'Win_NT4' Then; Filters out Windows NT 4.0Can I suggest you rename your variable $OS and $OSVer or you use directly the @.. It is a little confusing the way you define them. Link to comment Share on other sites More sharing options...
ZenKensei Posted April 3, 2004 Share Posted April 3, 2004 DOH!!!! JPM, you are absolutely correct!! Thats what I get for being hasty (and not having enough sleep...). Below is the 'cleaned up' code: If @OSType <> 'Win32_NT' Then; Filters out Windows 9x & ME clients Exit EndIf If @OSVersion = 'Win_NT4' Then; Filters out Windows NT 4.0 MsgBox(0, "Operating System", "Incorrect Operating System - Windows XP or 2000 Required") Exit (0) EndIf MsgBox(0, "Operating System", "Running Windows 2000 or XP") Thanks again for the callout, I hate passing along faulty script Z/K Link to comment Share on other sites More sharing options...
CyberSlug Posted April 3, 2004 Share Posted April 3, 2004 (edited) Another way to skin the proverbial cat:If (@OSType <> "Win32_NT") Or (@OSVersion = "Win_NT4") Then MsgBox(4096,"Error", "Incorrect OS; Win XP or 2000 required") Exit(1) EndIf MsgBox(0, "Note", "Proceeding with installation...")By the way, you could also do something like this:If StringInStr("Win_2000;Win_XP", @OSVersion) Then MsgBox(0,"","Correct OS") Edited April 3, 2004 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! 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