Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling .exe w/ ASP?

Status
Not open for further replies.

dlingo

Programmer
Nov 19, 2001
60
US
Is it possible to call an .exe file created in VB with ASP?
 

dlingo,

Yes, it is possible. But remember, if you run server side ASP, the executable will run on the server, not the client.

You would need to write a client-side script (VBscript or Javascript) for it to execute on the client.

fengshui_1998
 
For my application, I think I would want to store the .exe file on the server and run the file on the server as well. All my executable does is take an Access table that is on the server side and convert it to an Excel spreadsheet. Therefore, I think it would be fine to run the executable on the server. However, I want the newly created spreadsheet file to be saved to the client's local hard drive. Any further suggestions?

Thanks.
 
dlingo,

There are easier ways to do that by using SQL and using the following:

Response.ContentType = "application/vnd.ms-excel"

Do you have to run the executable?

fengshui_1998
 
I really appreciate your help. You've been extremely helpful. I think if I explained the process to you you'd understand why I am doing it this way. Of course, I may not be using the optimal solution. However, I need to work on another project that's come up. I will be in touch in the near future when this becomes a priority again. Again thanks.
 
hi..

I wanted to execute a particular exe file which was located at my IIS on a particular codition. So i wanted to execute an EXE file on IIS throu ASP.

Can u Please help me how it will be possible.

Thanks in advance,

Krishna Kishore
 

dlingo,

This will display your data on the client without having to create an Excel sheet on the server.


<%
Response.ContentType = &quot;application/vnd.ms-excel&quot;
%>

<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=1>

<tr><td>Row1</td><td>data1</td><td>data5</td></tr>
<tr><td>Row2</td><td>data2</td><td>data6</td></tr>
<tr><td>Row3</td><td>data3</td><td>data7</td></tr>
<tr><td>Row4</td><td>data4</td><td>data8</td></tr>
</TABLE>


Cheers,
fengshui_1998
 
FengShui1998:

You are right, I definately want to use VBScript to execute the .exe file on the client side. For some reason it's not working though. I'll include my code and give a description of what's up.

The executable file is outputExcel.exe and it is on the server.

Here is the code I used on my ASP page:

<%
Set Command = WScript.CreateObject(&quot;WScript.shell&quot;)
cmd = &quot;./outputExcel.exe&quot; 'error might be here, the .exe is in the same folder as the ASP page, so I wrote it this way.
Command.run (cmd)
%>

 


dlingo,

I created an ASP page that executed EXCEL and the EXCEL process shows in Task Manager. However, the browser can not display an executable or the output from an executable unless it creates an HTML page dynamically and then displays it on the fly.

You will not be able to see on the client any of the executable's out put directly.

The executable basically runs in the background and is not accessable through the web. At least, not yet. I believe .NET is working to make this happen.

As far as your code, don't use command because I believe there is a command already out there.

<%
Set Wsh = CreateObject(&quot;WScript.shell&quot;)
Wsh.run (&quot;yourdrive:\yourdirectory\outputExcel.exe)
%>


fengshui_1998
 
I don't need to make the Excel spreadsheet viewable to the user in the browser. The only thing I need to do is create the Excel spreadsheet on the user's local hard drive. The executable file does this properly when I execute it myself. However, I want it to run automatically in the background from the web page.

My application has a front-end that allows the user to create a temporary table in Access from a larger database using only the fields that the user wants. From here the user wants to be able to export this data into Excel, so that they can make graphs, etc. My front-end is working properly and creating the temporary table. The VB .exe that I created exports this temporary table into Excel (and creates an .xls file on the local hard drive) when I double click the .exe that is stored on the server, but as I said when the temporary table is created I would like all this to happen automatically instead of causing the user to have to execute the .exe file themselves.

I used your code above and the executible did not create the spreadsheet on the local hard drive. I don't know what to do. The one problem could be that the .exe file is on the server and in your code above it stipulates a local drive and local directory.

Here's my updated code.....

<%
Set Wsh = CreateObject(&quot;WScript.shell&quot;)
Wsh.run (&quot;%>

PS: The above IP is on a local server and is not connected to the internet, so there is no way you can test it from your machine.

Thanks in advance.....
 


dlingo,

Your statements are confusing. You say that your exe creates an Excel file on the local hard drive (Is this a browser client? or network connected? when you click on it on the server. How does your executable know where to save the .XLS file either from the browser or interactively?

Running an executable from a command line or VBscript is different than running from a browser. Can you clarify?


fengshui_1998
 
fengshui_1998,

I am using a local intranet here at work that is not connected to the internet.

The .exe file itself (written in VB 5.0) contains the destination directory for the spreadsheet file (this is how it knows where to store the .xls file). The destination directory is local to the user. However, the .exe file is stored on the same server that the ASP pages are stored.

Therefore, when I go to Windows Explorer and double click the .exe file (outputExcel.exe), it works properly (i.e., it takes the table that was created and exports that table into an .xls file that is stored on the user's local hard drive). However, when I try to call the .exe file from the ASP page it doesn't work properly. It doesn't appear in the Task Manager, and it doesn't create the .xls file.

I hope this helps....

 

dlingo,

First, you need to find if your web site allows you to run executables from the ASP page. Go to your Internet Service Manager, open it, go to your web site and right click on your web site to bring up it's properties.

There's an &quot;Execute permissions&quot; drop down. Select &quot;Scripts and executables&quot;. Try this first.

P.S. The code I gave you sends a table but opens an Excel spread sheet on the client without having to down load the file. It should work with any browser as long as the client has Excel loaded.

fengshui_1998
 
fengshui_1998,

I think you nailed my problem in your last post.

Let me start off by telling you that I am using Personal Web Server as a testing environment and that Personal Web Server is not installed on my computer.

When I run the ASP page on my machine the code above does not work. However, if I run the ASP page on the machine that Personal Web Server is installed on it works perfectly. I'm guessing this is because it's not allowing the .exe file to execute on another machine.

How do I allow this access w/ Personal Web Server (please explain the Internet Service Manager message from your last post)???
 


dlingo,

Internet Service Manager allows you to set up manage your FTP, web site and SMTP servers. It's found in Control Panel, Administrative Tools.

In particular, you can create and manage web site functionality and permissions. This is where you can set your ASP page to run executables or just run scripts.

Since you can execute your VB executable on your machine, you probably have rights to do that from NT authentication. However, your WEB site uses a different account. This keeps people from getting in thru your web site and mucking around with stuff you don't want them to. It's a little complex. Basically, you just want people to get access to your web pages and not your system executables.


fengshui_1998
 
Fengshui_1998,

You have been such a big help. I have the application working now, but a little different than I originally planned. The executable is executing on the server side, not the client side. Also, the Excel spreadsheet is being created on the server side and not the client side. That's the reason that it worked from the server test machine and not my machine. It was actually working from my machine, but was executing and saving the .xls file to the server.

Now all I have to do is write a downloading script to transfer that file from the server to the client. I don't know how to do that yet, but I will get it. Any suggestions?

I'm new to this site. Is there anywhere I can leave feedback about your responses?
 
dlingo,

Once your Excel file is created, you can refer to it in a link for downloading. This way you don't have to figure out if the drive exists, etc. unless you need to have it in a certain place. This will allow the user to save it wherever he/she wants to.

Example:

<body>
To down load, click
<a href=&quot;</body>



fengshui_1998
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top