How to launch a Windows application from a ASP.Net web application

  • Thread starter Thread starter JB
  • Start date Start date
J

JB

Hello Community

I have successfully created a C# Windows application with SQL Server in
the back end.

I have also successfully created an ASP.NET web application using C# and
SQL
Server in th back end.

Any more applications will be created with ASP.Net. I don't want to
rewrite the Windows application so I am curious, from the ASP.NET application
if I create a put a button or a link on the ASP.NET web application can I
launch
the C# Windows application from there and if so what is the command to
launch the C# Web application from the ASP.NET web application?

Thanks
Jeff
 
Hello Community

    I have successfully created a C# Windows application with SQL Server in
the back end.

    I have also successfully created an ASP.NET web application usingC# and
SQL
Server in th back end.

    Any more applications will be created with ASP.Net.  I don't want to
rewrite the Windows application so I am curious, from the ASP.NET application
if I create a put a button or a link on the ASP.NET web application can I
launch
the C# Windows application from there and if so what is the command to
launch the C# Web application from the ASP.NET web application?

    Thanks
    Jeff

Hello:
I don't think it's possible. Imagine that anyone could launch an
application on your computer, like "format C: /q", what a security
flaw! If you absolutely need it, try with Activex or java applets.
Best regards
 
Hello Cubaman

From a web application you can call a Windows application. I have seen
it done. When the Windows application gets executed a dialogue box appears
that says File Download - Security Warning. Then the name of the file which
is a batch file and its location. You have the option of Run, Save and
Cancel. If you click Run, you will see the application get executed in batch
mode.

I am just not sure how the batch program is being called from an ASP.NET
menu.

Does that give you any ideas on how that is setup to run like that, if so
how is it done?

fyi, the Windows application was setup using ClickOnce.

Thanks
Jeff
 
Hello Cubaman

    From a web application you can call a Windows application.  I have seen
it done.  When the Windows application gets executed a dialogue box appears
that says File Download - Security Warning.  Then the name of the file which
is a batch file and its location.  You have the option of Run, Save and
Cancel.  If you click Run, you will see the application get executed inbatch
mode.

    I am just not sure how the batch program is being called from an ASP.NET
menu.

    Does that give you any ideas on how that is setup to run like that, if so
how is it done?

    fyi, the Windows application was setup using ClickOnce.

    Thanks
    Jeff

Hello JB:
Well, if the user downloads and run any file from internet, it's not
you website the one running the app, but the user. Just place a link
to a bat file on your web menu and instruct your users to run it. The
problem I see here is getting the right path to your clickonce app, as
it's installed in Local App folder with a very long and obscure path
that will be different for each user.
If all your applications will be deployed via click once, a possible
solution is creating a page with links to your clickonce applications,
deployed in on-line execution mode only.
Let me know if you need further assistance. Best regards.
 
Hello Cubaman

I was thinking so far ahead I should have phrased the question differently
because I knew that a Windows application could be executed from a dos batch
file program because I saw it and since I used to write dos file batch
programs I knew how to create a batch file program already. So I went ahead
and created the batch program and it does work.

However:

When using ClickOnce it creates/deploys the Windows application (.exe) from
the local hard drive onto the server in a folder named Inetpub\wwwroot. The
file ClickOnce creates to install the Windows application from there onto the
client from there is named Publish.htm . Publish.htm then puts the
application in the users Start menu.

That means there is no Windows application.exe file created by ClickOnce for
the batch file to execute on the server.

So the batch file has to execute the actual Windows application (.exe) from
my ocal hard drive that it was created on which is what the user sees and
uses. That is how I created the batch file to work and it does work.

So the question actually is will the application that the user sees that
comes from
my local hard drive that I provide access to them work the exact same way as
the
application that gets deployed to them onto their local hard drive by
ClickOnce?

The reason that is the question is because the Windows application got
executed
from a Hyperlink control which states “runat=server, which means things in
the
Windows application like Messagebox.show may not work because Windows
applications run on the client not the server.

My thought is that when the batch program runs it is executing the Windows
application from my local hard drive and is therefore running from the hard
drive and not the server and was only rendered to the user using the
Hyperlink. Therefore since it executing off of my local hard drive those
features like Messagebox.show should work because they are not running on the
server. However I don’t know if multiple users are getting their own instance
of the application or is only one user able to use the application at a time.

Of course the Windows application (.exe) file will eventually be moved to a
server because my box isn’t on all of time.

What do you think?

Below is the dos batch file and below that is how the Hyperlink on the web
page executes the batch file:

***Batch file:prodTest.bat

cd c:\Products\bin\Release
c:\ Products\bin\Release \frmProducts.exe"

*** the call to the batch file from web page using Hyperlink

protected void lnkProducts_Click(object sender, EventArgs e)
{
ProcessStartInfo prodRun = new
ProcessStartInfo("C:\\Products\\prodTest.bat");
Process exProducts = new Process();

prodRun.UseShellExecute = true;
prodRun.WorkingDirectory = "C:\\Products\\";
exProducts = Process.Start(prodRun);
}

Thanks
Jeff
 
Hello Cubaman

I was thinking so far ahead I should have phrased the question differently
because I knew that a Windows application could be executed from a dos batch
file program because I saw it and since I used to write dos file batch
programs I knew how to create a batch file program already. So I went ahead
and created the batch program and it does work.  

However:

When using ClickOnce it creates/deploys the  Windows application (.exe)from
the local hard drive onto the server in a folder named Inetpub\wwwroot.  The
file ClickOnce creates to install the Windows application from there ontothe
client from there is named Publish.htm .  Publish.htm then puts the
application in the users Start menu.

That means there is no Windows application.exe file created by ClickOnce for
the batch file to execute on the server.

So the batch file has to execute the actual Windows application (.exe) from
my ocal hard drive that it was created on which is what  the user sees and
uses. That is how I created the batch file to work and it does work.

So the question actually is will the application that the user sees that
comes from
my local hard drive that I provide access to them work the exact same wayas
the
application that gets deployed to them onto their local hard drive by
ClickOnce?

The reason that is the question is because the Windows application got
executed
from a Hyperlink control which states “runat=server, which means things in
the
Windows application like Messagebox.show may not  work because Windows
applications  run on the client not the server.

My thought is that when the batch program runs it is executing the Windows
application from my local hard drive and is therefore running from the hard
drive and not the server and was only rendered to the user using the
Hyperlink.  Therefore since it  executing off of  my  local hard drive those
features like Messagebox.show should work because they are not running onthe
server. However I don’t know if multiple users are getting their own instance
of the application or is only one user able to use the application at a time.

Of course the Windows application (.exe) file will eventually be moved toa
server because my box isn’t on all of time.

What do you think?

Below is the dos batch file and below that is how the Hyperlink on the web
page executes the batch file:

***Batch file:prodTest.bat

cd c:\Products\bin\Release
c:\ Products\bin\Release \frmProducts.exe"

*** the call to the batch file from web page using Hyperlink

        protected void lnkProducts_Click(object sender, EventArgse)
        {
           ProcessStartInfo prodRun = new
ProcessStartInfo("C:\\Products\\prodTest.bat");
            Process exProducts = new Process();

            prodRun.UseShellExecute = true;
            prodRun.WorkingDirectory = "C:\\Products\\";
            exProducts = Process.Start(prodRun);
        }

    Thanks
    Jeff

You are wrong:
"When using ClickOnce it creates/deploys the Windows application
(.exe) from
the local hard drive onto the server in a folder named Inetpub
\wwwroot. The
file ClickOnce creates to install the Windows application from there
onto the
client from there is named Publish.htm . Publish.htm then puts the
application in the users Start menu.

That means there is no Windows application.exe file created by
ClickOnce for
the batch file to execute on the server."

Publish.htm just point to a file with application extension
(*.application) This file contains information needed to install and/
or run your app. If you publish it as a local app, then it will be
deployed to the user's local folder, something like "C:\Documents and
Settings\<username>\Local Settings\Apps\2.0\<x>\<y>
\<z>". If application is available only on-line, it's copied to a
local temp folder and executed.
You can not run a windows program embedded on a web page, not even
using "runat="server".
Please, read more about clickonce app deployment at:
http://msdn.microsoft.com/en-us/library/t71a733d.aspx
Best regards.
 
Hi Cuba man,

I can positively tell you that your lnkProducts_Click method is going to run
on the Web Server. There is no way for this to execute on the client.
Remember, the client is a browser! It can execute Java, ActiveX, and
JavaScript, and maybe a few other things.

The only reason your program has been somewhat successful is because your
client and server are on the same machine.

Click-Once is a method of deploying an application from a Web Server to a
client.

NOTE:
Client machines do not have a Inetpub\wwwroot folder unless they are running
their own IIS web server.

I hope this helps,
Mark

Hello Cubaman

I was thinking so far ahead I should have phrased the question differently
because I knew that a Windows application could be executed from a dos
batch
file program because I saw it and since I used to write dos file batch
programs I knew how to create a batch file program already. So I went
ahead
and created the batch program and it does work.

However:

When using ClickOnce it creates/deploys the Windows application (.exe)
from
the local hard drive onto the server in a folder named Inetpub\wwwroot.
The
file ClickOnce creates to install the Windows application from there onto
the
client from there is named Publish.htm . Publish.htm then puts the
application in the users Start menu.

That means there is no Windows application.exe file created by ClickOnce
for
the batch file to execute on the server.

So the batch file has to execute the actual Windows application (.exe)
from
my ocal hard drive that it was created on which is what the user sees and
uses. That is how I created the batch file to work and it does work.

So the question actually is will the application that the user sees that
comes from
my local hard drive that I provide access to them work the exact same way
as
the
application that gets deployed to them onto their local hard drive by
ClickOnce?

The reason that is the question is because the Windows application got
executed
from a Hyperlink control which states “runat=server, which means things in
the
Windows application like Messagebox.show may not work because Windows
applications run on the client not the server.

My thought is that when the batch program runs it is executing the Windows
application from my local hard drive and is therefore running from the
hard
drive and not the server and was only rendered to the user using the
Hyperlink. Therefore since it executing off of my local hard drive those
features like Messagebox.show should work because they are not running on
the
server. However I don’t know if multiple users are getting their own
instance
of the application or is only one user able to use the application at a
time.

Of course the Windows application (.exe) file will eventually be moved to
a
server because my box isn’t on all of time.

What do you think?

Below is the dos batch file and below that is how the Hyperlink on the web
page executes the batch file:

***Batch file:prodTest.bat

cd c:\Products\bin\Release
c:\ Products\bin\Release \frmProducts.exe"

*** the call to the batch file from web page using Hyperlink

protected void lnkProducts_Click(object sender, EventArgs e)
{
ProcessStartInfo prodRun = new
ProcessStartInfo("C:\\Products\\prodTest.bat");
Process exProducts = new Process();

prodRun.UseShellExecute = true;
prodRun.WorkingDirectory = "C:\\Products\\";
exProducts = Process.Start(prodRun);
}

Thanks
Jeff

You are wrong:
"When using ClickOnce it creates/deploys the Windows application
(.exe) from
the local hard drive onto the server in a folder named Inetpub
\wwwroot. The
file ClickOnce creates to install the Windows application from there
onto the
client from there is named Publish.htm . Publish.htm then puts the
application in the users Start menu.

That means there is no Windows application.exe file created by
ClickOnce for
the batch file to execute on the server."

Publish.htm just point to a file with application extension
(*.application) This file contains information needed to install and/
or run your app. If you publish it as a local app, then it will be
deployed to the user's local folder, something like "C:\Documents and
Settings\<username>\Local Settings\Apps\2.0\<x>\<y>
\<z>". If application is available only on-line, it's copied to a
local temp folder and executed.
You can not run a windows program embedded on a web page, not even
using "runat="server".
Please, read more about clickonce app deployment at:
http://msdn.microsoft.com/en-us/library/t71a733d.aspx
Best regards.
 
Back
Top