roofninja Posted April 21, 2007 Share Posted April 21, 2007 This is part of a program and this is the only part that does not work. I have been searching for days and trying different things but I can't seem to figure it out. What am I don't wrong? Why can't I compare $pcmodel in the if statement? Thanks for any help. CODE$count = 0 RunWait(@ComSpec & " /c " & "systeminfo >sysinfo.txt") $file = FileOpen("sysinfo.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached or line 26 is reached. While 1 $line = FileReadLine($file) $count=$count+1 If @error = -1 or $count=26 Then ExitLoop $line = String($line) $line = StringSplit($line, ":") if $count=14 then ;model $pcmodel = StringTrimLeft($line[2], (23)) endif Wend FileClose($file) ;$pcmodel = "D505" --this works ;$pcmodel = "GX110" --this does not work Why? ;this if does not work now. if $pcmodel = "GX110" or $pcmodel = "GX150" or $pcmodel = "GX1" then $cputype = " PentiumIII Processor" ;test output ;$cputype = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{50127DC3-0F36-415E-A6CC-4CB3BE910B65}000", "DriverDesc") $cputype = String($cputype) $len = StringLen($cputype) $cputype = StringTrimLeft($cputype, ($len-20)) else $cputype = " Intel® Pentium® 4 CPU 2.80GHz" ;test output ;$cputype = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor", "ProcessorNameString") $cputype = String($cputype) $len = StringLen($cputype) $result = StringInStr($cputype,"P",0,1) $cputype = StringTrimLeft($cputype, ($len-$result)) endif MsgBox(0, "Line read:", "PC MODEL:"&$pcmodel&".") MsgBox(0, "CPUTYPE:", "your cpu is:"&$cputype&".") RUN . . . Slide . . . TAG . . . Your out . . . PAINTBALL !!! Link to comment Share on other sites More sharing options...
SkinnyWhiteGuy Posted April 21, 2007 Share Posted April 21, 2007 Well, I haven't tried your code or anything, but just as a matter of coding habit, I always use == for checking things in If statements. In AutoIt, either will work, with = not caring about case with strings, and == being case sensitive. I'd suggest trying that. If that doesn't work, I'm out of ideas at the moment. Link to comment Share on other sites More sharing options...
Shevilie Posted April 21, 2007 Share Posted April 21, 2007 if ($pcmodel == "GX110") or ($pcmodel == "GX150") or ($pcmodel == "GX1") then try that Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit Link to comment Share on other sites More sharing options...
roofninja Posted April 21, 2007 Author Share Posted April 21, 2007 I did not know about using ==. I did just try it and it did not work. Does anybody have a different way of doing this? RUN . . . Slide . . . TAG . . . Your out . . . PAINTBALL !!! Link to comment Share on other sites More sharing options...
Shevilie Posted April 21, 2007 Share Posted April 21, 2007 Try running this solo script $pcmodel = "GX110" If ($pcmodel == "GX110") Or ($pcmodel == "GX150") Or ($pcmodel == "GX1") Then MsgBox(0,0,"Worked") EndIf Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit Link to comment Share on other sites More sharing options...
roofninja Posted April 21, 2007 Author Share Posted April 21, 2007 Try running this solo script $pcmodel = "GX110" If ($pcmodel == "GX110") Or ($pcmodel == "GX150") Or ($pcmodel == "GX1") Then MsgBox(0,0,"Worked") EndIf I have tried that. That was the next thing that I tried. It does work that way, but it does not work when I run it through the first part of the script. That is a mystery to me. It still is a mystery to me. How else am I going to find and determine what the CPU is? I need to know if it is a P2, P3, P4, celeron, or a PM, etc. On the systems that I am using that information is located in different places. I have determined that the first three get there info from the same place and everything else is somewhere else. Is there a command line program that will get it? RUN . . . Slide . . . TAG . . . Your out . . . PAINTBALL !!! Link to comment Share on other sites More sharing options...
Shevilie Posted April 22, 2007 Share Posted April 22, 2007 I think your problem is $pcmodel = StringTrimLeft($line[2], (23)) You might have a @crlf or a space or something here Try echo it out like this MsgBox(0,0,"-" & $pcmodel & "-") Else try this $count = 0 RunWait(@ComSpec & " /c " & "systeminfo >sysinfo.txt") $file = FileOpen("sysinfo.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached or line 26 is reached. While 1 $line = FileReadLine($file) $count=$count+1 If @error = -1 or $count=26 Then ExitLoop $line = String($line) $line = StringSplit($line, ":") if $count=14 then ;model $pcmodel = StringTrimLeft($line[2], (23)) endif Wend FileClose($file) If ($pcmodel == "GX110") Or ($pcmodel == "GX150") Or ($pcmodel == "GX1") Then MsgBox(0,0,"Worked") Else MsgBox(0,0,"-" & $pcmodel & "-") MsgBox(0,0,StringLen($pcmodel)) EndIf Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit Link to comment Share on other sites More sharing options...
roofninja Posted April 23, 2007 Author Share Posted April 23, 2007 I think your problem is $pcmodel = StringTrimLeft($line[2], (23)) You might have a @crlf or a space or something here Try echo it out like this MsgBox(0,0,"-" & $pcmodel & "-") Else try thisThanks for your suggestion. That was it. I had trailing spaces that I did not notice. On an different note. After thinking and searching, I found a solution that turns out to be better. I do use an external program but it works better than I thought it would. Thanks anyway. I really appreciate your help. RUN . . . Slide . . . TAG . . . Your out . . . PAINTBALL !!! Link to comment Share on other sites More sharing options...
Shevilie Posted April 23, 2007 Share Posted April 23, 2007 np Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit 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