polara Posted December 5, 2007 Share Posted December 5, 2007 I am building a script to run a Robocopy backup of user data on Vista workstations. Since the data locations are different in Vista, I need to confirm that the script is running only on Vista machines. Can anyone help with some code to: 1. Detect if the OS is Win XP. 2. If yes, pop up a warning window and a button to close the script. 3. If no, continue script. Thanks. Link to comment Share on other sites More sharing options...
Nahuel Posted December 5, 2007 Share Posted December 5, 2007 @OSVersion Link to comment Share on other sites More sharing options...
Valuater Posted December 5, 2007 Share Posted December 5, 2007 Maybe... ; @OSVersion ; Returns one of the following: "WIN_VISTA", "WIN_2003", "WIN_XP", "WIN_2000", "WIN_NT4", "WIN_ME", "WIN_98", "WIN_95" If @OSVersion = "WIN_XP" Then MsgBox(0x0, "WIN_XP", "Do this.... ") If @OSVersion = "WIN_VISTA" Then MsgBox(0x0, "WIN_VISTA", "Do this.... ") 8) Link to comment Share on other sites More sharing options...
polara Posted December 5, 2007 Author Share Posted December 5, 2007 Maybe... ; @OSVersion ; Returns one of the following: "WIN_VISTA", "WIN_2003", "WIN_XP", "WIN_2000", "WIN_NT4", "WIN_ME", "WIN_98", "WIN_95" If @OSVersion = "WIN_XP" Then MsgBox(0x0, "WIN_XP", "Do this.... ") If @OSVersion = "WIN_VISTA" Then MsgBox(0x0, "WIN_VISTA", "Do this.... ") 8) This looks good and it does check the OS. However, 2 Things: 1. I probably don't need the If @OSVersion = "WIN_VISTA" line since I only care if it's XP. I assume I can just remove this? 2. If it is XP, what do I need to add to - If @OSVersion = "WIN_XP" Then MsgBox(0x0, "WIN_XP", "Do this.... ") - to halt the script with a "close" button? Thanks again. Link to comment Share on other sites More sharing options...
realkiller Posted December 8, 2007 Share Posted December 8, 2007 look in the helpfile under msgbox there you find alle the msgbox codes:) Remote 3.1 BetaRemote Media Player ControlUSB Security 1.2 Link to comment Share on other sites More sharing options...
GEOSoft Posted December 8, 2007 Share Posted December 8, 2007 If @OSVersion <> "Win_Vista" Then MsgBox(0x0, "Error", "This application will not run on your version of Windows" & @CRLF & "The application will now close.") Exit EndIf 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...
polara Posted December 10, 2007 Author Share Posted December 10, 2007 If @OSVersion <> "Win_Vista" Then MsgBox(0x0, "Error", "This application will not run on your version of Windows" & @CRLF & "The application will now close.") Exit EndIf Running this in XP or Vista produces the error: EndIf Error:"EndIf" statement with no matching "If" statement. Link to comment Share on other sites More sharing options...
Nahuel Posted December 10, 2007 Share Posted December 10, 2007 Running this in XP or Vista produces the error: EndIfError:"EndIf" statement with no matching "If" statement.No, it doesn't... Link to comment Share on other sites More sharing options...
polara Posted December 10, 2007 Author Share Posted December 10, 2007 No, it doesn't...Hmm.. Maybe the problem is what I have following this. Here's my entire script:; ----------------------------------------------------------------------------;; AutoIt Version: 3.1.0; Author: ;; Script Function: ; Robocopy backup for Vista users;; ----------------------------------------------------------------------------; Robocopy Backup - For Vista Only v1.1 12-10-2007; @OSVersion; Returns one of the following: "WIN_VISTA", "WIN_2003", "WIN_XP", "WIN_2000", "WIN_NT4", "WIN_ME", "WIN_98", "WIN_95"If @OSVersion <> "Win_Vista" Then MsgBox(0x0, "Error", "This backup is for Vista only. Please run the Win XP backup" & @CRLF & "The application will now close.") ExitEndIf$ol = ObjGet("", "outlook.Application")If @error Then $ol = ObjCreate("outlook.Application") ;no outlook to grab onto EndIf$update = MsgBox(1, "Backup", "Backup needs to close Outlook before it can run. Click Ok to continue or Cancel if you do not want to close Outlook at this time.")If $update = 2 Then MsgBox(0, "Backup", "Backup has been canceled.") Exit EndIf$ol.quit;EndIfRunWait("\\myserver\share\Scripts\dbu_Vista.cmd")MsgBox(0, "Backup", "Backup has finished. Please remember to run backup regularly.");This errors if Outlook is already closed Link to comment Share on other sites More sharing options...
Nahuel Posted December 10, 2007 Share Posted December 10, 2007 Here's your problem: If @OSVersion <> "Win_Vista" Then MsgBox(0x0, "Error", "This backup is for Vista only. Please run the Win XP backup" & @CRLF & "The application will now close.") Exit EndIf If you do If <condition> then <code>, you don't need the Endif cos you did it in one line. This is how that should be: If @OSVersion <> "Win_Vista" Then MsgBox(0x0, "Error", "This backup is for Vista only. Please run the Win XP backup" & @CRLF & "The application will now close.") Exit EndIf Link to comment Share on other sites More sharing options...
polara Posted December 10, 2007 Author Share Posted December 10, 2007 Here's your problem: If @OSVersion <> "Win_Vista" Then MsgBox(0x0, "Error", "This backup is for Vista only. Please run the Win XP backup" & @CRLF & "The application will now close.") Exit EndIf If you do If <condition> then <code>, you don't need the Endif cos you did it in one line. This is how that should be: If @OSVersion <> "Win_Vista" Then MsgBox(0x0, "Error", "This backup is for Vista only. Please run the Win XP backup" & @CRLF & "The application will now close.") Exit EndIfWow! What a difference a CR makes. Thanks for your patience and help. You are awesome..... 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