Click here to Skip to main content
Licence CPOL
First Posted 27 Mar 2007
Views 14,951
Downloads 74
Bookmarked 9 times

ASP Application installer using Javascript

By | 4 Aug 2010 | Article
How to install an ASP.NET application using Javascript. This will register your application in IIS, create a start menu entry and desktop icon.

Introduction

This is an application for those who want to install .NET web applications but do not want to create a setup application. The code presented in this article can be used to create an easy installer.

Background

This application is developed using Javascript.

Using the code

You can use the following install and uninstall Javascript in your application and also the Javascript file available in common folder

The Javascript for for installing an application is as follows:

<script language="JScript">
////////////////////////////////////////////////////////////////
function window.onload()
////////////////////////////////////////////////////////////////
{
    if (document.location.protocol != "file:")
    {
        alert("This application must be run under the file protocol")
        window.close()
        return
    }
    document.all.virtualDir.value = "TestInstall"
    document.all.virtualDir.readOnly = true
    initTabbedContent()
    populateWebsiteList()
    document.title = Product + " Installation"
    sizeWindow()
}

////////////////////////////////////////////////////////////////
function installSuite()
////////////////////////////////////////////////////////////////
{
    var cwd = WshShell.CurrentDirectory;

    for ( var i = 0; i < ProductArray.length -1; i++ )
    {
        Product = ProductArray[i];
        PublicFolders = PublicFoldersArray[i];
        WshShell.CurrentDirectory = "./" + Product + "/";
//        WshShell.Run( "install.hta auto", 2, true )

        install(true); 
        WshShell.CurrentDirectory = cwd;
    }     
    Product = ProductArray[ ProductArray.length-1 ];
    PublicFolders = PublicFoldersArray[ ProductArray.length-1 ];
    document.getElementById("virtualDir").value = Product;
    document.getElementById("virtualDir").originalValue = Product;
    install();
    updateText( "Test installation complete.");
}
</script>

The script to uninstall an application is as follows:

<script language="JScript" src="common/uninstall.js"></script>
<script language="JScript">
var SubProductArray = 
[
    //Define your sub folders here
];
////////////////////////////////////////////////////////////////
function window.onload()
////////////////////////////////////////////////////////////////
{
    if (!loadInstallationProperties())
    {
        alert("Cannot load installation properties file install.xml");
        window.close();
    }
    webSite = getInstallationProperty("website");
    virtualDir = getInstallationProperty("virtualdir");
    product = getInstallationProperty("product");
    shortProduct = product.split(".")[0];
    dotNet = true;

    installshield = 
      (TestUnInstall.commandLine.toLowerCase().indexOf("installshield") >= 0);
    sizeWindow();
    if (installshield)
    {
        document.all.buttonRow.style.display = "none";
        uninstallSuite();
        window.close();
    }
}
////////////////////////////////////////////////////////////////
function uninstallSuite()
////////////////////////////////////////////////////////////////
{
    var preservedVirtualDir = virtualDir;

    updateText("Beginning uninstall");
    for (var i = 0; i < SubProductArray.length; i++)
    {
        virtualDir = SubProductArray[ i ];
        removeVirtualFolder();
    }
    virtualDir = preservedVirtualDir;
    uninstall();
}
</script>

Points of Interest

During development of this application I learned how Javascript can be powerful on the client side. I also learned how to change the web.config file at installation time.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Moiz hakimi

Web Developer

Kuwait Kuwait

Member

Moiz Hakimi is a Software engineer at Expert Solutions Kuwait.
He has worked with .Net technologies in web development and has been programming since 2005.
He is very comfortable in various languages,RDBMS & platforms from C++,C# to VB.NET with Access & MS SQLServer
from Javascript,AJAX to ASP.NET.
 
Besides programming he loves playing guitar, listening to music,singing, bike riding & cricket.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 3 PinmemberZiad Elmalki23:32 2 Jan '11  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 4 Aug 2010
Article Copyright 2007 by Moiz hakimi
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid