Jump to content

IF statement


Shawndt
 Share

Recommended Posts

I am trying to get this if statement to work but I am running into a problem. The statement will not display if the app is not on the machine.

$var1 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\uninstall\{3248F0A8-6813-11D6-A77B-00B0D0160060}\", "DisplayName")

$var2 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\uninstall\{90120000-0020-0409-0000-0000000FF1CE}\", "DisplayName")

$var3 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\uninstall\{AC76BA86-7AD7-1033-7B44-A91000000001}\", "DisplayName")

IF $var1 = 0 Then

MsgBox(4096, "Java:", $var1)

Else

MsgBox(4096, "Java", "Java App Not found")

EndIf

MsgBox(4096, "ComPack 2007:", $var2)

MsgBox(4096, "Adobe:", $var3)

Link to comment
Share on other sites

Why are you using "IF $var1 = 0 Then"? The display name is a string that does not represent an integer, so in a numerical compare it is converted to 0. Therefore "Some Display Name" = 0 is true because your variable types don't match. Maybe this would be better:

If StringInStr($var1, "Java") Then

:D

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
Link to comment
Share on other sites

Why are you using "IF $var1 = 0 Then"? The display name is a string that does not represent an integer, so in a numerical compare it is converted to 0. Therefore "Some Display Name" = 0 is true because your variable types don't match. Maybe this would be better:

If StringInStr($var1, "Java") Then

:D

I tried the below. The first one works not the others. They say they cannot be found. Which they are on the machine. I can return the value easily. I just think I have the If statement mixed up.

If StringInStr($var1, "Java") Then

MsgBox(4096, "Java:", $var1)

Else

MsgBox(4096, "Java", "Java App Not found")

Endif

IF

StringInStr($var2, "ComPack 2007") Then

MsgBox(4096, "ComPack 2007:", $var2)

Else

MsgBox(4096, "ComPack 2007", "Office ComPack 2007 Not found")

Endif

If stringInstr($Var3, "Adobe 9.1") Then

MsgBox(4096, "Adobe 9.1", $Var3)

Else

MsgBox(4096, "Adobe 9.1", "Adobe 9.1 Not Found")

EndIF

Link to comment
Share on other sites

@shawndt: Stop posting the crappy formatting. Tidy the code in SciTE (CTRL-t), and put it in code tags (the button that looks like "<>"). I can't tell if you really think IF and ELSE can be on separate lines like that (hint: NO).

:D

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
Link to comment
Share on other sites

So why did you change the way $var2 and $Var3 are processed?

$var1 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\uninstall\{3248F0A8-6813-11D6-A77B-00B0D0160060}\", "DisplayName")
$var2 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\uninstall\{90120000-0020-0409-0000-0000000FF1CE}\", "DisplayName")
$var3 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\uninstall\{AC76BA86-7AD7-1033-7B44-A91000000001}\", "DisplayName")


If StringInStr($var1, "Java") Then

MsgBox(4096, "Java:", $var1)

Else 

MsgBox(4096, "Java", "Java App Not found")

End If

I am not changing it just calling the variable for each. Like I said if I create another if statement, it will only run App not found in the statement. Instead of returning the variable.

Link to comment
Share on other sites

You're still not posting the code you're talking about. If you ran Tidy (Ctrl-t) on that, or just the syntax checker (Ctrl-F5) you would know that "End If" is invalid. Your code doesn't show another If statement, so where are you having the not found issue?

:D

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
Link to comment
Share on other sites

You're still not posting the code you're talking about. If you ran Tidy (Ctrl-t) on that, or just the syntax checker (Ctrl-F5) you would know that "End If" is invalid. Your code doesn't show another If statement, so where are you having the not found issue?

:mellow:

PSalt

Thanks for your help. I was not aware of those tools. I got it working. By chance would you know where in the registry is there is a location. In which, you can find out the directories that are Encrypted by Microsoft EFS?

I want to to do a RegRead()

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...