ARTICLE

How to remotely load an executable file in ASP.NET

Posted by Yuan Wang Articles | January 09, 2007
Tags:
A simple ASP.NET sample to load an executable file (or an application) remotely from internet.
 
Reader Level:

If you want to load an executable file (or an application) remotely, we give a simple ASP.NET with VB.NET program.

----- one button remoteReboot.aspx file -------------

<%@ Page language="vb" Codebehind="remoteReboot.aspx.vb" AutoEventWireup="false" Inherits="Universal.Datatransfer.ExcelOracle.remoteReboot" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<HTML>

 <HEAD>

  <title>remoteReboot</title>

  <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">

  <meta name="CODE_LANGUAGE" Content="VB">

  <meta name="vs_defaultClientScript" content="JavaScript">

  <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">

 </HEAD>

 <body MS_POSITIONING="GridLayout">

  <form id="Form1" method="post" runat="server">

   <asp:Button id="Button1" runat="server"

    Text="Remote Reboot" Width="128px"></asp:Button>

  </form>

 </body>

</HTML>

----- remoteReboot.aspx.vb file -------------

Imports System

Imports System.Collections

Imports System.ComponentModel

Imports System.Data

Imports System.Drawing

Imports System.Web

Imports System.Web.SessionState

Imports System.Web.UI

Imports System.Web.UI.WebControls

Imports System.Web.UI.HtmlControls

Namespace Universal.Datatransfer.ExcelOracle

    '<summary>

    ' Summary description for remoteReboot.

    ' </summary>

 

    Public Class remoteReboot

        Inherits System.Web.UI.Page

        Protected Button1 As System.Web.UI.WebControls.Button

 

        Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

            'Put user code to initialize the page here

        End Sub

#Region "Web Form Designer generated code"

 

        Protected Overrides Sub OnInit(ByVal e As EventArgs)

            ' CODEGEN: This call is required by the ASP.NET Web Form Designer.

            InitializeComponent()

            MyBase.OnInit(e)

        End Sub

 

        Private Sub InitializeComponent()

            AddHandler Me.Button1.Click, AddressOf Me.Button1_Click

            AddHandler Me.Load, AddressOf Me.Page_Load

        End Sub

#End Region

 

        Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)

            Dim myProcess1 As System.Diagnostics.Process = New System.Diagnostics.Process

            myProcess1.StartInfo.WorkingDirectory = Request.MapPath("~/bin")

            myProcess1.StartInfo.FileName = Request.MapPath("~/bin/notepad.exe")

            myProcess1.Start()

        End Sub

    End Class

End Namespace 

 

Procedures:

  1. Copy an excecutable file into your web-root bin directory, for example, notepad.exe.

  2. Window XP and Windows Server 2003 have the different settings.

    For Window XP users, edit machine.config file in C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\CONFIG change the userName from Machine into SYSTEM as below,

    <processModel enable="true", ..., userName="SYSTEM" password="AutoGenerate" ... maxIoThreads
    ="20"/>

    For Windows Server 2003 users, you have to set up in a little different way. Just send me an email if you need a help.

  3. If you don't want to application to run under background,  you have to go to \Administrative Tools\Services\IIS Admin and right click Property\Logon, then click the checkbox of Allow service to interact with desktop.

If you don't set (3), your application is still loaded. But it runs under background.

After restart computer, then you can remote load the executable file from the internet.

NOTE: THIS ARTICLE IS CONVERTED FROM C# TO VB.NET USING A CONVERSION TOOL. ORIGINAL ARTICLE CAN BE FOUND ON C# CORNER (http://www.c-sharpcorner.com/).

Login to add your contents and source code to this article
share this article :




post comment
 
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Nevron Diagram
Become a Sponsor