Jump to content

IfThens Not Working


xd1936
 Share

Recommended Posts

Hey guys... quick scripting n00b question, if anyone can help me out, that'd me appreciated. I'm using this to make sure no browsers are running when this script is run:

$ff = ProcessExists("firefox.exe")
$ie = ProcessExists("iexplore.exe")
$ch = ProcessExists("chrome.exe")
$sf = ProcessExists("Safari.exe")
$op = ProcessExists("Opera.exe")
If $ff = 1 then
    MsgBox(16, "Error - Firefox is running. Exit Firefox and Restart" )
    Exit
EndIf
If $ie = 1 then
    MsgBox(16, "Error - Internet Explorer is running. Exit Internet Explorer and Restart" )
    Exit
EndIf
If $ch = 1 then
    MsgBox(16, "Error - Google Chrome is running. Exit Google Chrome and Restart" )
    Exit
EndIf
If $sf = 1 then
    MsgBox(16, "Error - Apple Safari for Windows is running. Exit Safari for Windows and Restart" )
    Exit
EndIf
If $op = 1 then 
    MsgBox(16, "Error - Opera Browser is running. Exit Opera and Restart" )
    Exit
EndIf

But even though I run it with Firefox running, it still shows no message boxes. Any help? ;)

Link to comment
Share on other sites

Hey guys... quick scripting n00b question, if anyone can help me out, that'd me appreciated. I'm using this to make sure no browsers are running when this script is run:

$ff = ProcessExists("firefox.exe")
$ie = ProcessExists("iexplore.exe")
$ch = ProcessExists("chrome.exe")
$sf = ProcessExists("Safari.exe")
$op = ProcessExists("Opera.exe")
If $ff = 1 then
    MsgBox(16, "Error - Firefox is running. Exit Firefox and Restart" )
    Exit
EndIf
If $ie = 1 then
    MsgBox(16, "Error - Internet Explorer is running. Exit Internet Explorer and Restart" )
    Exit
EndIf
If $ch = 1 then
    MsgBox(16, "Error - Google Chrome is running. Exit Google Chrome and Restart" )
    Exit
EndIf
If $sf = 1 then
    MsgBox(16, "Error - Apple Safari for Windows is running. Exit Safari for Windows and Restart" )
    Exit
EndIf
If $op = 1 then 
    MsgBox(16, "Error - Opera Browser is running. Exit Opera and Restart" )
    Exit
EndIf

But even though I run it with Firefox running, it still shows no message boxes. Any help? ;)

ProcessExists returns the PID of the process if it exist not True or 1

Change your if statments to

If $ff > 0 then
    MsgBox(16, "Error - Firefox is running. Exit Firefox and Restart" )
    Exit
EndIf

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

ProcessExists returns the PID of the process if it exist not True or 1

Change your if statments to

If $ff > 0 then
    MsgBox(16, "Error - Firefox is running. Exit Firefox and Restart" )
    Exit
EndIf
Got it... I should've paid closer attention, my apologies. Thanks
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...