.NET Framework - How to launch a Windows application from a ASP.Net web application

Asked By JB on 26-Aug-10 07:09 PM
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 do not 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
--
JB




Cubaman replied to JB on 30-Aug-10 03:46 AM
ver in
C# and
nt to
tion

Hello:
I do not think it is 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
JB replied to Cubaman on 30-Aug-10 09:44 PM
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


--
JB
Cubaman replied to JB on 31-Aug-10 04:12 AM
ave seen
ears
which
batch
ASP.NET
t, if so
Server in
sing C# and
t want to
lication
an I
o

Hello JB:
Well, if the user downloads and run any file from internet, it is 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 is 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.
JB replied to Cubaman on 31-Aug-10 09:50 PM
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



--
JB
Cubaman replied to JB on 01-Sep-10 03:58 AM
y
tch
ad
from
=A0The
the
for
om
and
as
gs in
s
rd
drive those
the
stance
ime.
a
b
e)
=A0I have seen
appears
ile which
and
d in batch
an ASP.NET
that, if so
SQL Server in
on using C# and
do not want to
application
on can I
nd to

You are wrong:
(.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 is copied to a
local temp folder and executed.
You can not run a windows program embedded on a web page, not even
using "runat=3D"server".
Please, read more about clickonce app deployment at:
http://msdn.microsoft.com/en-us/library/t71a733d.aspx
Best regards.
Mark Northup replied to Cubaman on 06-Oct-10 09:33 AM
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


You are wrong:
(.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 is 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.