Jump to content
Sign in to follow this  
xd1936

IfThens Not Working

Recommended Posts

xd1936

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? ;)

Share this post


Link to post
Share on other sites
Bowmore

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

Share this post


Link to post
Share on other sites
xd1936

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

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.