How can I call notepad.exe within ASP.net

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I use asp.net(webform) to finish my web site
For some reason,I need to call notepad.exe in my WebForm
For example,when client users click a button in my web page,it will call
notepad.exe to show
But I do not know how to write the code
Can anyone help me
Thank you!
my email is :[email protected]
 
Don't post your real email address in a newsgroup as it will be picked up by
spambots and you will increase the amount of spam you get. Also, people
here don't generally respond directly to others via personal email. We just
post the response in the newsgroup so everyone can see the answer.

The code is: System.Diagnostics.Process.Start("path to application or
file")

But, I should really warn you against doing this. You won't be starting the
local user's copy of Notepad (which you can't do from the server), you'll be
opening Notepad on the server, which the client can't do anything with.

What is it exactly that you are trying to accomplish?
 
I want web users in Lan can download their own excel files form server
So I write VBA code in the Excel ,which can get only their personal data form SQL server
I alse wrote a simple program(test.exe) by vb.net(winform) to do this
This automatic process is
Web user-->click webform button-->call test.exe-->than test.exe will call excel to finish the report--> and than show it in the brower

So I want webform(aspx) to call my winform program in the web page
That's all

Is there any thother way to do the processes
If you have any better propose
Thank you!


----- Scott M. wrote: ----

Don't post your real email address in a newsgroup as it will be picked up b
spambots and you will increase the amount of spam you get. Also, peopl
here don't generally respond directly to others via personal email. We jus
post the response in the newsgroup so everyone can see the answer

The code is: System.Diagnostics.Process.Start("path to application o
file"

But, I should really warn you against doing this. You won't be starting th
local user's copy of Notepad (which you can't do from the server), you'll b
opening Notepad on the server, which the client can't do anything with

What is it exactly that you are trying to accomplish
 
Still not sure how NotePad comes into play. Why not skip the WinForm app
all together? Just have your ASP.NET page call Excel to produce the report
you need and then grab the Excel data and show it back on your WebForm?

No local application to worry about. No downloading involved at all.


Arron said:
I want web users in Lan can download their own excel files form server.
So I write VBA code in the Excel ,which can get only their personal data form SQL server.
I alse wrote a simple program(test.exe) by vb.net(winform) to do this.
This automatic process is :
Web user-->click webform button-->call test.exe-->than test.exe will
call excel to finish the report--> and than show it in the brower.
 
Because I try it already
In my testing , When I use the code:.......Create Object("Excel.application")..........
It show's error message such as "Can not create Active X object........
My webForm(aspx) can not create Active X control like Excel.application.But the same code in WinForm ,it's works
So ,I think maybe webform(aspx) can not call excel.exe directly
Is that correct?
Or could you please to show me the sample code : how webform call Excel.exe directly
Thank for your suggest
 
Arro
If a csv file, which Excel can read, will do the job then you can use something like the FileSystemObject (that was in ASP I'm not sure what its equivalent is in ASP.Net) to create a file from text that you create/parse from the form data in your application. There are all sort of issues about not automating Office Apps from a server process - see KB articles 224338, 288366, 288367 and 288368
Microsoft warn against doing it
 
In ASP.NET you don't use the CreateObject method. Your code to gain access
to Excel is wrong that's all, it doesn't mean you can't do it.

1. Make reference to the Excel object library
2. Create an instance of Excel, a workbook and a worksheet (something like
below, I'm working from memory):

Dim xl as new Excel.Application()
Dim wb as Excel.Workbook = xl.Workbooks.Add()
Dim ws as Excel.Worksheet = wb.Worksheets.Add()

3. Do what you need to do with the worksheet
4. Copy worksheet back to web form



Arron said:
Because I try it already.
In my testing , When I use the code:.......Create Object("Excel.application")...........
It show's error message such as "Can not create Active X object........ "
My webForm(aspx) can not create Active X control like
Excel.application.But the same code in WinForm ,it's works.
 
Thank you for your response
But I do not know how to find out KB articles 224338, 288366, 288367 and 288368
Can you teach me
Thank you!
 
Thank you for the response.
But
1. my Excel files was already exists.
2. it's a little complex for the Excel format.
So I wrote a lot of VBA code in the Excel.
Can I call the Excel files and sends values directly , and than it will automatic
produce the report?
 
Only I want is to call notepad.exe in webform.
I post my code below.Just one line.
Is anything wrong?

Private Sub Button1_Click(...)...
Process.Start("notepad.exe", "")
End Sub

When I click button1 on the webForm , The taskmanager
add a process named notepad.exe,but it's not show in the
window.Not thing happens,what's wrong?
 
1. my Excel files was already exists.

So? That makes it easier. The user can either enter the file path or
you can give them a control that lets them browse to it.
2. it's a little complex for the Excel format.

Theses are already Excel files aren't they? Excel files are too
complicated for Excel?
So I wrote a lot of VBA code in the Excel.

And my point was to migrate that code to the web page instead.
Can I call the Excel files and sends values directly , and than it will
automatic produce the report?

But what would you do with that report? That's my point. Use Excel to
generate the data and then take that data and bring it back into your web
page and use your web page to display it.
 
This returns me back to my original point. Your one line of code will start
Notepad on the web server, not the client. Since, while you are developing,
you are using just one machine to act as the client and the server, it's
easy to forget that.
 
Back
Top