50% OFF!!!

Saturday, February 13, 2016

Free Javascript Obfuscator Online

Protects JavaScript code from stealing/reading and shrinks its size.
Free Javascript Obfuscator is a professional tool for obfuscation of javascript. It Converts JavaScript source code into scrambled and completely unreadable form, preventing it from analyzing and theft.
Visit: http://freejsobfuscator.com/

u can choose if to process by your will: parameters / functions / strings / new lines / indentations and it is 100% free!

Sunday, November 22, 2015

How to install php imap extension on Centos (or any)

The php package (extension) for IMAP is usually:

Sometimes, for example on amazon ec2, when installing PHP ver. 5.5 or 5.6,
In order to install this (or any other) PHP extension,
that not come with the default PHP,
You should installed the one related to your PHP version.

For example,
one of my servers have PHP 5.6 installed on it,
but when running 
 yum install php-imap 
which gives:
Error: php56-imap conflicts with php-imap-5.3.29-1.8.amzn1.x86_64
Error: php56-common conflicts with php-common-5.3.29-1.8.amzn1.x86_64
Error: php55-common conflicts with php-common-5.3.29-1.8.amzn1.x86_64
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest 

so instead, check first which version currently installed:
yum list installed | grep php
 which gives:
php56.x86_64                          5.6.14-1.119.amzn1           @amzn-updates
php56-cli.x86_64                      5.6.14-1.119.amzn1           @amzn-updates
php56-common.x86_64                   5.6.14-1.119.amzn1           @amzn-updates
php56-imap.x86_64                     5.6.14-1.119.amzn1           @amzn-updates
php56-jsonc.x86_64                    1.3.6-1.19.amzn1             @amzn-main
php56-mbstring.x86_64                 5.6.14-1.119.amzn1           @amzn-updates
php56-mysqlnd.x86_64                  5.6.14-1.119.amzn1           @amzn-updates
php56-pdo.x86_64                      5.6.14-1.119.amzn1           @amzn-updates
php56-process.x86_64                  5.6.14-1.119.amzn1           @amzn-updates
php56-xml.x86_64                      5.6.14-1.119.amzn1           @amzn-updates 

Which means that your PHP version is 5.6 (you can also run php -v)
php -v
 which gives:
PHP 5.6.14 (cli) (built: Oct 16 2015 22:58:32)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies

All needed now is to install the correct version.
If you install php55-imap (or any other package) it won't work!
Some have several PHP versions installed.
yum install php56-imap

don't forget to restart your apache after that.
service httpd restart

and done... :)
Hope it helps.

Friday, November 13, 2015

PHP | XML to Html Table elment convertion

In this thread,
I will show generic & universal function that
gets XML string,
convert it,
and display it as an HTML table.
(you can add any css style to design your table later on of course)

The following code is using XML example from http://www.w3schools.com/xml/simple.xml.
The XML looks like that:
    <name>Belgian Waffles</name>
    <description>Two of our famous...</description>
    <name>Strawberry Belgian Waffles</name>
    <description>Light Belgian waffles...</description>
    <name>Berry-Berry Belgian Waffles</name>
    <description>Light Belgian....</description>
    <name>French Toast</name>
    <description>Thick slices made....</description>
    <name>Homestyle Breakfast</name>
    <description>Two eggs, bacon...</description>

The function xmlToHtmlTable 
gets a SimpleXMLElement parameter which points to main parent for which will print all his children,
and returns html table representing the XML as string.

The Code:
 // get XML remotely / locally / or / just set it as string '<root>...</root>'  
 $sXml = file_get_contents('http://www.w3schools.com/xml/simple.xml');  
 // parse XML  
 $oXML = simplexml_load_string($sXml);  
 if (!$oXML) {  
      die('xml format not valid or simplexml module missing.');  
 // assuming running the root  
 $oXmlRoot = $oXML; // or can be [$oXML->food]  
 //echo '<pre>'; print_r( $oXmlRoot ); echo '</pre>';  
 echo xmlToHtmlTable($oXmlRoot);  
 function xmlToHtmlTable($p_oXmlRoot) {  
      $bIsHeaderProceessed = false;  
      $sTHead = '';  
      $sTBody = '';       
      foreach ($p_oXmlRoot as $oNode) {  
           $sTBody .= '<tr>';  
           foreach ($oNode as $sName => $oValue){  
                if (!$bIsHeaderProceessed) {  
                     $sTHead .= "<th>{$sName}</th>";  
                $sValue = (string)$oValue;  
                $sTBody .= "<td>{$sValue}</td>";                 
           $bIsHeaderProceessed = true;  
           $sTBody .= '</tr>';  
      $sHTML = "<table border=1>  
      return $sHTML;  

This will output:

Hope it helps!


Friday, June 19, 2015

MySQL | find median (Nth element) without join!

This is my suggestion to find on mysql select command
the Median (Nth element) without joining the table to itself (or to new custom one).

My method, uses string manipulation
so I'm not sure it is good for big tables.
(I tested it with medium size tables on Mysql 5.5.28)

The advantage of this method, 
that it works also if we need to find the MEDIAN for each group in the select query.

the code is using: SUBSTRING_INDEX and GROUP_CONCAT methods.

Here is test code for test table:
DROP TABLE test.test_median
CREATE TABLE test.test_median AS
SELECT 'book' AS grp, 4 AS val UNION ALL


SELECT 'bike', 26 

and the code for finding the median for each group:
         SUBSTRING_INDEX( SUBSTRING_INDEX( GROUP_CONCAT(val ORDER BY val), ',', COUNT(*)/2 ), ',', -1) as the_median,
         GROUP_CONCAT(val ORDER BY val) as all_vals_for_debug
FROM test.test_median

The output:

grp the_median all_vals_for_debug
bike 22 22,26
book 4 2,2,3,4,7,8,9
note 11 11

Hope it helps you there...

Wednesday, May 27, 2015

php | destroy/delete all sessions

I recently searched for an option deleting all running/active sessions,
for changing some important logic on my server.

just restarting apache won't help!
because php handles php-sessions by itself.

I wonder how to make it, without changing php code.
The solution, is to delete the PHP session files created by PHP engine.

Step #1 - find where PHP store php files
on php.ini there is configured session.save_path 
which points to the correct path.
by default, it configured to "" (empty), and it is:

  • On Ubuntu or Debian machines: saved on /var/lib/php5
  • On RHEL and CentOS systems: saved on /var/lib/php/session
  • If you need to find it: print session_save_path() on your php file.    You may run from command line:  php -r 'echo session_save_path(), "\n";'

Step #2 - just delete the files
Execute the following bash script:
rm  -f   /var/lib/php/session/*
rm  -f   /var/lib/php5/sess*
(-f will force delete without prompting!!) 

And that's it...
Now when a user will execute web-request, 
his session will be considered empty, 
and will be re-generated (under the same session name)

Thursday, December 25, 2014

NSIS | create CENTER aligned text control

I searched on the internet for CENTER LABEL on NSIS,
but didn't find.

I saw that the ${SS_CENTER} style, not working with ${NSD_CreateLabel}
So I build my own code, using the STATIC control.

nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${SS_CENTER} 0 29 180 439 60 "WELCOME TEXT"
Pop $0
CreateFont $1 "Arial" 9
SendMessage $0 ${WM_SETFONT} $1 1
SetCtlColors $0 0x000000 '0xff0000'

Hope it help...

Wednesday, February 13, 2013

c# Winforms WebBrowser - Clear all cookies

I recently search for a method to delete all cookies from the build in .NET WinForms WebBrowser control.
I didn't found any working solution for it, nor working example.
It being told to use InternetSetOption, but nothing found about it.
So, i will write here my solution for clearing and deleting all cookies.
My solution using InternetSetOption with the option flag: INTERNET_OPTION_SUPPRESS_BEHAVIOR, which described as:

A general purpose option that is used to suppress behaviors on a process-wide basis. The lpBuffer parameter of the function must be a pointer to a DWORD containing the specific behavior to suppress. This option cannot be queried with InternetQueryOption.

This option flag should be used together with INTERNET_SUPPRESS_COOKIE_PERSIST options, which means:

Suppresses the persistence of cookies, even if the server has specified them as persistent.

So the example code for it will be:
static void Main()

    Application.Run(new Form1());

[System.Runtime.InteropServices.DllImport("wininet.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
public static extern bool InternetSetOption(int hInternet, int dwOption, IntPtr lpBuffer, int dwBufferLength);

private static unsafe void SuppressWininetBehavior()
    /* SOURCE: http://msdn.microsoft.com/en-us/library/windows/desktop/aa385328%28v=vs.85%29.aspx
        *      A general purpose option that is used to suppress behaviors on a process-wide basis. 
        *      The lpBuffer parameter of the function must be a pointer to a DWORD containing the specific behavior to suppress. 
        *      This option cannot be queried with InternetQueryOption. 
        *      Suppresses the persistence of cookies, even if the server has specified them as persistent.
        *      Version:  Requires Internet Explorer 8.0 or later.

    int option = (int)3/* INTERNET_SUPPRESS_COOKIE_PERSIST*/;
    int* optionPtr = &option;

    bool success = InternetSetOption(0, 81/*INTERNET_OPTION_SUPPRESS_BEHAVIOR*/, new IntPtr(optionPtr), sizeof(int));
    if (!success)
        MessageBox.Show("Something went wrong !>?");

Please make sure your project is allows unsafe code. (under Properties => Build Tab)

This code is deleting the COOKIES per PROCESS on startup ONLY.
[tested on WIN-7 and working great]

Best Regards,

Sunday, February 10, 2013

MySQL xpath ExtractValue with delimiter

I recently noticed the XPATH option inside MySQL.
What a wonderfull way for handling XML. (http://dev.mysql.com/doc/refman/5.1/en/xml-functions.html)
I used ExtractFunction, and noticed that this function is space delimited:
Because ExtractValue() returns multiple matches as a single space-delimited string

So I needed to create the same function with custom text delimted (comma, semi-colon or anything you want).

The function called: EXTRACTVALUE_ALL which is the same as EXTRACTVALUE just get a delimiter text to seperate between results. (seperated text).
Tested on MySQL 5.5.28.

Create Function CODE:

DECLARE total_elements INT;
DECLARE xpath_expression_count, xpath_expression_index  TEXT;
DECLARE single_tag, result  TEXT;

# calc TOTAL elements
SET xpath_expression_count = CONCAT('count(', p_xpathExpr, ')');
SELECT EXTRACTVALUE(p_xml, xpath_expression_count) INTO total_elements;

# run over elements (create long text)
SET result = '';
SET xpath_expression_index = CONCAT(p_xpathExpr, '[$@i]');
SET @i = 1;
WHILE @i <= total_elements DO
SET single_tag = EXTRACTVALUE(p_xml, xpath_expression_index);
SET result = IF(result='', single_tag, CONCAT(result, p_delimiter, single_tag));
SET @i = @i + 1;

# return total result
RETURN result;

Usage Code:
SET @XXXMMMMLLL = '      ';

SELECT EXTRACTVALUE_ALL(@XXXMMMMLLL, '/descendant-or-self::time', '  |  ');

time1  |  time2

Rememeber that you will need a MYSQL permission for creating new functions.



Wednesday, January 2, 2013

NSIS - Launch a program as user from UAC elevated installer

NSIS - Launch a program as user from UAC elevated installer

I noticed that if a program is running as UAC elevated (admin or high user privileges), 
any opening process by this process will get the same privileges as the executing program,
which means, that any process opened by this UAC elevated program will be elevated also.

I found a solution for it, for opening the process UN-ELEVATED from ELEVATED running program.
I show this information as for NSIS installer, but can be used in ANY development environment (C#, NSIS, C++, JAVA, VB, and any).

The idea is to run the process in UN-ELEVATED mode, using windows's file explorer process `explorer.exe` (info).
Lets say the process that we want to launch is on `$TEMP\MyUnElevatedProcess.exe`.
So, for NSIS code, I will just write:

Exec '"$WINDIR\explorer.exe" "$TEMP\MyUnElevatedProcess.exe"'

And this will do the work...
The process `MyUnElevatedProcess.exe` will run with same ELEVATION that have your windows login, as have `$WINDIR\explorer.exe`.

Execute with parameters:
In addition, if the UN-ELEVATED process need to executed with parameters, you will need to create another file that executes the UN-ELEVATED process (for example a BATCH file which just run the process with the command line parameters).
a good example can be:
; assuming that the file `MyUnElevatedProcess.exe` exists on `$TEMP\`

; create shortcut with ARGUMENTS
CreateShortCut "$TEMP\Shortcut.lnk" "$TEMP\MyUnElevatedProcess.exe" "/arg1 /arg2 /arg3"

; execute the file NON elevated
Exec '"$WINDIR\explorer.exe" "$TEMP\Shortcut.lnk"'

if your main program (the executing), is not ELEVATED, this logic is not relevant, because then you can just run `Exec` (open-process function in NSIS) which will have the same elevation as your process.

I hope it helps,

Sunday, May 22, 2011

c# WinForm | Check form window size and location


I wanted to open a new window form, exactly near another form. (pinning one form to another).
Because of the border difference among Windows XP, Vista and Windows7 (win7), it didn't work easily.

So to determine windows size under win7/vista, I had to check if Windows Aero. (checking made by short&easy code)

Now, after checking this, I had to also support winXP (which does not have AERO technology).

For finding the left and right window border size (width) I used the SystemInformation Class which provides information about the current system environment.

I recommend to check if it works for other FormBorderStyle.

The code:
internal static bool IsAeroEnabled()
    bool isEnabled = false;
    if (Environment.OSVersion.Version.Major >= 6)
            DwmIsCompositionEnabled(out isEnabled);
        catch (Exception ex)
    return isEnabled;
internal static extern int DwmIsCompositionEnabled(out bool enabled);

Best regard,
MDB Blog

Monday, May 2, 2011

Check HOSTS file - C# WinForms


In today's post i'm giving a good (and simple) anti-hacking tool which allow your application to CHECK for any changes in the Windows HOSTS file.

So, the operation is simple:
Just read the hosts file content, and validate that your site DNS is not included in the list.
[basiclly, check if hosts file contains your dns name]
if so, the user probably is trying to bypass your server so you can stop him from doing so.

The code:
static bool IsDnsByPassed(string p_dnsName)
    string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), @"drivers\etc\hosts");
    string hostsText = File.ReadAllText(path);
    return hostsText.ToLower().Contains(p_dnsName.ToLower());

Although reading the HOSTS file is allowed to all user, do not try to edit the HOSTS file, because on Vista & Windows7 this operation is allowed only for administrators. if your application is NOT running as Admin, then you won't have permission for this (and an Exception will be thrown).

Best regard,

Thursday, February 10, 2011

MSI | Embed images inside MSI installer file

In this post I show how to embed images inside MSI installer file.

The first try i made was to try adding splash image and banners to the installer through Visual-Studio User-Interface. (just added two jpg files into "Common Files Folder", and set the SplashBitmap and BannerBitmap attributes). But doing so, created a problem - when changing the image, new version installer did NOT changed the images (or the images disappeared).
So i needed another solution...

The next solution is just to INSERT those images (banner&splash) directly into the MSI file created by Visual-Studio.
I created file run.js file, which automaticlly runs when the build process finished, and edits the MSI. This is achieved by setting the PostBuildEvent on the Windows Installer project.

The event that added is to the PostBuildEvent: (remember to copy the file to the main folder of the Windows Installer project)
cscript.exe "$(ProjectDir)run.js" "$(BuiltOuputPath)"

In this way, you don't have to add any image file to your project, and it s embedded in the msi file (which u can edit any time).

The run.js file:
// run.js // Performs a post-build fixup of an msi

if (WScript.Arguments.Length != 1)
       WScript.StdErr.WriteLine(WScript.ScriptName + " file");

var filespec = WScript.Arguments(0);
var installer = WScript.CreateObject("WindowsInstaller.Installer");
var database = installer.OpenDatabase(filespec, 1/*msiOpenDatabaseModeTransact*/);

var sql
var view
var record

try {

    WScript.Echo("UPDATE default banner image");

    sql = "UPDATE `Binary` SET `Data` = ? WHERE `Name`= 'DefBannerBitmap'";
    view = database.OpenView(sql)
    record = installer.CreateRecord(1);
    record.SetStream(1, "C:\\installer_banner_img.jpg");
       WScript.Echo("ADD splash image");
    sql = "INSERT INTO `Binary` (`Name`, `Data`) VALUES ('DefSplashBitmap', ?)";
    view = database.OpenView(sql)
    record = installer.CreateRecord(1);
    record.SetStream(1, "C:\\Installer_splash_img.jpg");

    WScript.Echo("Update splash control");
    sql = "UPDATE `Control` SET `Text`='DefSplashBitmap' WHERE `Dialog_`='SplashForm' AND `Control`='SplashBmp'";
    view = database.OpenView(sql)
catch (e) {
    WScript.StdErr.Write("|||ERROR||| ");

Before running this script, add a splash screen to the installer (using User-Interface view in Visual Studio)

(*) this is also a good example how to add/update binary(image) into your MSI using a sql script.

Best regard,

Tuesday, February 1, 2011

C# | Determine if Adobe (Macromedia) Flash player installed.

All started when I needed to integrate an Adobe (Macromedia) Flash object in my C# WinForm application.
I saw several posts about it, where two solutions where presents:
1. Add WebBrowser Control and just nevigate to the "test.swf" file.
2. Create COM object of ADOBE MACROMEDIA.

I liked the 1st option more, because I don't need to handle COM objects (and to add another DLL to the app).
Here is the code I used:
WebBrowser wb = new WebBrowser();
//wb.Location = SOME LOCATION
//wb.Size = SOME SIZE
wb.AllowNavigation = false;
wb.IsWebBrowserContextMenuEnabled = false;
this.Controls.Add(wb); // this = FORM

BUT, Then i noticed that when a pc do NOT have Adobe (Macromedia) Flash player installed, the webbrowser display a big red X.
SO, before I use the FLASH image in my winform application, I needed to check if FLASH player is INSTALLED or not!

The idea is to check the registry for:

And indeed it worked!
Here is the full code for testing if FLASH installed (and also get the major Version):
internal static int? GetFlashPlayerVersion()
    using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Macromedia\FlashPlayer"))
        if (rk != null)
            string version = rk.GetValue("CurrentVersion") as string;
            if (string.IsNullOrEmpty(version) == false)
                int idx = version.IndexOf(",");
                if (idx > 0)
                    int value;
                    if (int.TryParse(version.Substring(0, idx), out value) == true)
                        return value;
    return null;

And the code which using the method:
int? flashVersion = WindowsUtils.GetFlashPlayerVersion();
if (flashVersion.HasValue == true && flashVersion > 6)
    WebBrowser wb = new WebBrowser();
    wb.AllowNavigation = false;
    wb.IsWebBrowserContextMenuEnabled = false;
    this.Controls.Add(wb); // this = FORM

Best regards,

Wednesday, December 8, 2010

C# | Check if app is installed for “All users” or "Just me"

Today I bring a very HARD-to-find topic about getting an installed application "Installation context".
An installation context may be Per-Machine Installation Context (ALLUSERS=1) and Per-User Installation Context (ALLUSERS="").

When installing an application, the user may select one of two options:
a. Install [APP] for yourself
b. or for anyone who uses this computer

[a] installs only for the current user(just me) while [b] installs for the Local System user which is for all-users(everyone).

In this post I will give a code for checking is an installed application was installed for "Everyone" or "Just me".

The validation process is check if the APPLICATION-NAME exists in the registry keys under UserData.
(*) Everyone - check under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\ (S-1-5-18 represents the Local System user)

(*) Just me (Current user) - check under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-?!?!?!?!\Products\ (S-?!?!?!?! represents the Current user. this value found by the code: WindowsIdentity.GetCurrent().User.Value.

[Code] Method's return type:
private enum InstallationContexts { NotInstalled, Everyone, JustMe };

[Code] Method declaration:
private InstallationContexts GetInstalledContext(string p_appDisplayName)
    //The S-1-5-18  =
Local System user (Everyone) | HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\

    //The S-XXXXXX  =
Current user (Just me)       |

    string key;
    string keyFormat = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\{0}\Products\";
    // Check if installed for -> Everyone
    key = string.Format(keyFormat, "S-1-5-18");
    bool res = GetInstalledContext_IsRegKeyExists(key, p_appDisplayName, StringComparison.OrdinalIgnoreCase);
    if (res == true)
        return InstallationContexts.Everyone;
    // Check if installed for -> Just me
    key = string.Format(keyFormat, WindowsIdentity.GetCurrent().User.Value);
    res = GetInstalledContext_IsRegKeyExists(key, p_appDisplayName, StringComparison.OrdinalIgnoreCase);
    if (res == true)
        return InstallationContexts.JustMe;
    return InstallationContexts.NotInstalled;
private bool GetInstalledContext_IsRegKeyExists(string p_regKey, string p_appDisplayName, StringComparison p_scompare)
    using (RegistryKey regkey = Registry.LocalMachine.OpenSubKey(p_regKey))
        if (regkey != null)
            RegistryKey rk;
            string[] arrProducs = regkey.GetSubKeyNames();
            for (int i = 0; i < arrProducs.Length; i++)

               using (rk = regkey.OpenSubKey(arrProducs[i] + @"\InstallProperties"))
if (rk != null &&
                        p_appDisplayName.Equals(rk.GetValue("DisplayName").ToString(), p_scompare) == true)
                        return true;
    return false;

[Code] Method's usage example:
InstallationContexts appContext = GetInstalledContext("APP-DISPLAY-NAME");

This code gives the ability to detect previously installed application or previously installed software is installed to ALLUSERS (everyone) or only to CURRENT USER (just me).

Addition on 19.12.2010:
(*) This checking operation is valid ONLY for an application and software which were installed using Microsoft's Windows Installer.
For general checking for installed application, check my post about check if program/application is installed.


Thursday, December 2, 2010

C# | check if program/application is installed on remote computer

As an advance to my previous post about checking if a program or an application is installed on my comptuer, I bringing a code for doing this validation on a remote computer.

The code is the same as checking for installed app in local comptuer (as described here) except that checking remote machine registry.
The remote machine registry checking is preformed using the static method OpenRemoteBaseKey of the class RegistryKey.

The code:
public static bool IsAppInstalled(string p_machineName, string p_name)
   string keyName;
   // search in: CurrentUser
   keyName = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
   if (ExistsInRemoteSubKey(p_machineName, RegistryHive.CurrentUser, keyName, "DisplayName", p_name) == true)
      return true;
   // search in: LocalMachine_32
   keyName = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
   if (ExistsInRemoteSubKey(p_machineName, RegistryHive.LocalMachine, keyName, "DisplayName", p_name) == true)
      return true;
   // search in: LocalMachine_64
   keyName = @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall";
   if (ExistsInRemoteSubKey(p_machineName, RegistryHive.LocalMachine, keyName, "DisplayName", p_name) == true)
      return true;
   return false;
private static bool ExistsInRemoteSubKey(string p_machineName, RegistryHive p_hive, string p_subKeyName, string p_attributeName, string p_name)
   RegistryKey subkey;
   string displayName;
   using (RegistryKey regHive = RegistryKey.OpenRemoteBaseKey(p_hive, p_machineName))
      using (RegistryKey regKey = regHive.OpenSubKey(p_subKeyName))
         if (regKey != null)
            foreach (string kn in regKey.GetSubKeyNames())
               using (subkey = regKey.OpenSubKey(kn))
                  displayName = subkey.GetValue(p_attributeName) as string;
                  if (p_name.Equals(displayName, StringComparison.OrdinalIgnoreCase) == true) // key found!
                     return true;
   return false;

How to use this code:
bool isAppInstalled = IsAppInstalled(MACHINE_NAME, APPLICATION_NAME);
  string msg = string.Format("Application '{0}' is {1} on the remote-machine '{2}'!",
isAppInstalled ? "installed" : "NOT installed",
catch (Exception ex)