0

I am using a asp.net MVC4 web application ,in which I need to install a software from ftp if the client machine not already installed it. During installation writing some data to the registry of the client machine , like:

Test
 |__DefaultIcon
 |__Shell
      |__Open
           |__command

Where in Test write something like below in registry.enter image description here

This entry will occur only after installing the software.So I can automatically initialise the software next time somebody try to download it,machine already have the software. To initialise the software using the below code:

 <script type="text/javascript">
            function LaunchURLScript() {
                var url = "Test:";

                // Creates an object which can read files from the server
                var reader = new XMLHttpRequest();
                // Opens the file and specifies the method (get)
                // Asynchronous is true

                   reader.open('GET', url, true);

                //check each time the ready state changes
                //to see if the object is ready



                reader.onreadystatechange = checkReadyState;

                function checkReadyState() {


                    if (reader.readyState === 4) {



                        //check to see whether request for the file failed or succeeded
                        if ((reader.status == 200) || (reader.status == 0)) {

                            //page exists -- redirect to the checked
                            //checked for page
                            // document.location.href = url;

                            window.open(url);
                            self.focus();
                        }
                        else {
                            alert("456");
                            //does nothing and quits the function
                            //if the url does not exist
                            return;

                        }

                    }//end of if (reader.readyState === 4)

                }
                // end of checkReadyState()

                // Sends the request for the file data to the server
                // Use null for "get" mode
                try{
                    reader.send(null);
                }

                catch (err) {
                    alert(err.message);
                } 
            }

        </script>

But the problem is window.open(url) will exicute evenif the url not exist,which means software not installed.Please help to find out whether the url exist or not before calling window.open(url)

neethu
  • 193
  • 1
  • 3
  • 14

0 Answers0