Jump to content
Sign in to follow this  
rdasheiff

If-ElseIf not working

Recommended Posts

This code isn't working.

If the file wmplayer.exe is corrupted, then FileGetVersion generates errorlevel 1 and the messagebox correctly prints out 'Windows Media Player - Trojan'.

If the file wmplayer.exe is ok, no message.

So far, so good.

If the 2nd file shlwapi.dll is corrupted, the 2nd messagebox should print out 'Shell Light-weight Utility Library - Spyware' (whether wmplayer.exe generated errorlevel 0 or 1) but it doesn't print, even though I can confirm it's returning errorlevel 1 with my diagnostics - MsgBox(0,"ErrorLevel2",@error)

If I Remark out all If and ElseIf and EndIf statements, all prints out.

If I Remark out the 1st If, and replace ElseIf with If, it also works.

And my Diagnostics of the extra MsgBox report correct errorlevels.

Stumped!

CODE

--------------------------------------------------------------------------

$ver1 = FileGetVersion("c:\progra~1\window~1\wmplayer.exe")

If @error = 1 Then

$size1 = FileGetSize("c:\progra~1\window~1\wmplayer.exe")

$s1="Correct version 9.0.0.2980" & @TAB & "Correct size 73728" & @LF

$s2="Detected version " & $ver1 & @TAB & "Detected size " & $size1 & @LF & @LF

$s3="Location: C:\Program Files\Window Media Player\wmplayer.exe"

$s = $s1 & $s2 & $s3

MsgBox(0, "Windows Media Player - Trojan", $s)

MsgBox(0,"ErrorLevel1",@error)

;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

$ver2 = FileGetVersion("c:\windows\sysbckup\shlwapi.dll")

MsgBox(0,"ErrorLevel2",@error)

ElseIf @error = 1 Then

$size2 = FileGetSize("c:\windows\sysbckup\shlwapi.dll")

$s1="Correct version 5.50.4134.600" & @TAB & "Correct size 300304" & @LF

$s2="Detected version " & $ver2 & @TAB & "Detected size " & $size2 & @LF & @LF

$s3="Location: C:\windows\system\shlwapi.dll" & @LF & @LF

$s4="Backup: C:\windows\sysbckup\shlwapi.dll"

$s = $s1 & $s2 & $s3 & $s4

MsgBox(0, "Shell Light-weight Utility Library - Spyware", $s)

EndIf

MsgBox(0,"ErrorLevel3",@error)

--------------------------------------------------------------------------

Share this post


Link to post
Share on other sites

This will work with no errors if there are no errors, I had to mod the directory locations for XP pro

FileGetVersion(@ProgramFilesDir & "\windows media player\wmplayer.exe")
If @error = 1 Then
$ver1 = FileGetVersion(@ProgramFilesDir & "\windows media player\wmplayer.exe")
$size1 = FileGetSize(@ProgramFilesDir & "\windows media player\wmplayer.exe")
$s1="Correct version 9.0.0.2980" & @TAB & "Correct size 73728" & @LF
$s2="Detected version " & $ver1 & @TAB & "Detected size " & $size1 & @LF & @LF
$s3="Location: "& @ProgramFilesDir & "\windows media player\wmplayer.exe"
$s = $s1 & $s2 & $s3
MsgBox(0, "Windows Media Player - Trojan", $s)
EndIf
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
FileGetVersion(@SystemDir & "\shlwapi.dll")
If @error = 1 Then
$ver2 = FileGetVersion(@SystemDir & "\shlwapi.dll")
$size2 = FileGetSize(@SystemDir & "\shlwapi.dll")
$s1="Correct version 5.50.4134.600" & @TAB & "Correct size 300304" & @LF
$s2="Detected version " & $ver2 & @TAB & "Detected size " & $size2 & @LF & @LF
$s3="Location:"& @SystemDir & "\shlwapi.dll" & @LF & @LF
$s4="Backup:"& @SystemDir & "\shlwapi.dll"
$s = $s1 & $s2 & $s3 & $s4
MsgBox(0, "Shell Light-weight Utility Library - Spyware", $s)
EndIf

I used this to test with errors

FileGetVersion(@ProgramFilesDir & "\windows media player\wmplayer1.exe")
If @error = 1 Then
$ver1 = FileGetVersion(@ProgramFilesDir & "\windows media player\wmplayer.exe")
$size1 = FileGetSize(@ProgramFilesDir & "\windows media player\wmplayer.exe")
$s1="Correct version 9.0.0.2980" & @TAB & "Correct size 73728" & @LF
$s2="Detected version " & $ver1 & @TAB & "Detected size " & $size1 & @LF & @LF
$s3="Location: "& @ProgramFilesDir & "\windows media player\wmplayer.exe"
$s = $s1 & $s2 & $s3
MsgBox(0, "Windows Media Player - Trojan", $s)
EndIf
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
FileGetVersion(@SystemDir & "\shlwapi1.dll")
If @error = 1 Then
$ver2 = FileGetVersion(@SystemDir & "\shlwapi.dll")
$size2 = FileGetSize(@SystemDir & "\shlwapi.dll")
$s1="Correct version 5.50.4134.600" & @TAB & "Correct size 300304" & @LF
$s2="Detected version " & $ver2 & @TAB & "Detected size " & $size2 & @LF & @LF
$s3="Location:"& @SystemDir & "\shlwapi.dll" & @LF & @LF
$s4="Backup:"& @SystemDir & "\shlwapi.dll"
$s = $s1 & $s2 & $s3 & $s4
MsgBox(0, "Shell Light-weight Utility Library - Spyware", $s)
EndIf

since there are no files by that name I get an error on both and they both work.

The whole app works on my machine now

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...