moorsey Posted August 26, 2009 Share Posted August 26, 2009 I have written a script that installs some software. But depending on the computer name, enters a different serial code (each code can be applied to a varying number of PCs depending on when it was bought etc). Only problem is, the script only ever enters the first serial code and never chooses any others. Could anyone suggest why this is? if @ComputerName = "PCVN121" or "PCVN122" or "PCVN123" or "PCVN124" or "PCVN125" Then send("serial code 1 {enter}") ElseIf @ComputerName = "PCVN126" or "PCVN127" or "PCVN128" or "PCVN129" or "PCVN1210" Then send("serial code 2 {enter}") ElseIf @ComputerName = "PCVN1211" or "PCVN1212" or "PCVN1213" or "PCVN1214" or "PCVN1215" Then send("serial code 3 {enter}") ElseIf @ComputerName = "PCVN21" or "PCVN22" or "PCVN23" or "PCVN24" or "PCVN25" Then send("serial code 4 {enter}") ElseIf @ComputerName = "PCVN26" Then send("serial code 5 {enter}") ElseIf @ComputerName = "PCVN27" Then send("serial code 6 {enter}") ElseIf @ComputerName = "PCVN28" Then send("serial code 7 {enter}") ElseIf @ComputerName = "PCVN29" Then send("serial code 8 {enter}") ElseIf @ComputerName = "PCVN210" Then send("serial code 9 {enter}") EndIf Link to comment Share on other sites More sharing options...
Nutster Posted August 26, 2009 Share Posted August 26, 2009 I have written a script that installs some software. But depending on the computer name, enters a different serial code (each code can be applied to a varying number of PCs depending on when it was bought etc). Only problem is, the script only ever enters the first serial code and never chooses any others. Could anyone suggest why this is? if @ComputerName = "PCVN121" or "PCVN122" or "PCVN123" or "PCVN124" or "PCVN125" Then send("serial code 1 {enter}") ElseIf @ComputerName = "PCVN126" or "PCVN127" or "PCVN128" or "PCVN129" or "PCVN1210" Then send("serial code 2 {enter}") ElseIf @ComputerName = "PCVN1211" or "PCVN1212" or "PCVN1213" or "PCVN1214" or "PCVN1215" Then send("serial code 3 {enter}") ElseIf @ComputerName = "PCVN21" or "PCVN22" or "PCVN23" or "PCVN24" or "PCVN25" Then send("serial code 4 {enter}") ElseIf @ComputerName = "PCVN26" Then send("serial code 5 {enter}") ElseIf @ComputerName = "PCVN27" Then send("serial code 6 {enter}") ElseIf @ComputerName = "PCVN28" Then send("serial code 7 {enter}") ElseIf @ComputerName = "PCVN29" Then send("serial code 8 {enter}") ElseIf @ComputerName = "PCVN210" Then send("serial code 9 {enter}") EndIf In If and ElseIf, each condition is independent. That is to say, that in each condition separated by "or", the variable must be restated. If @ComputerName = "Mach1" OR @ComputerName = "Mach2" OR @ComputerName = "Mach3" Then In this situation, where you are comparing one value to a series of values, using a Switch statement is more efficient. Switch (@ComputerName) Case "PCVN121", "PCVN122", "PCVN123", "PCVN124", "PCVN125" Send("serial code 1 {enter}") Case "PCVN126", "PCVN127", "PCVN128", "PCVN129", "PCVN1210" Send("serial code 2 {enter}") Case "PCVN1211", "PCVN1212", "PCVN1213", "PCVN1214", "PCVN1215" Send("serial code 3 {enter}") Case "PCVN21", "PCVN22", "PCVN23", "PCVN24", "PCVN25" Send("serial code 4 {enter}") Case "PCVN26" Send("serial code 5 {enter}") ; etc. EndSwitch David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd... Link to comment Share on other sites More sharing options...
moorsey Posted August 26, 2009 Author Share Posted August 26, 2009 ahhh, that makes sense, great! Really appreciate the information, lots to learn to get efficient at AutoIt! Will hopefully save me a lot of time on manual software installs though! Thanks again 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