473,408 Members | 2,402 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Process.Start() not starting


In the follwoing code, myProcess.StartInfo.FileName is set to a valid path:
c:\\hello.doc

The code produces the following error message: "%1 is not a valid Win32
application"

For c:\\hello.doc, I would expect the following code to open a Word document
in a normal window.
//code++++++++++++++++++++++++++++++++
Process myProcess = new Process();

try
{
LinkButton btnClicked = (LinkButton)sender;
int myID = 1;
myClass.GetByID(myID);
myProcess.StartInfo.FileName = myClass.myDirectory + myClass.myFileName;
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.WindowStyle =
System.Diagnostics.ProcessWindowStyle.Normal;
myProcess.StartInfo.CreateNoWindow = false;
myProcess.Start();
}

catch (Exception ex)
{

//end code++++++++++++++++++++++++++++++++

Thank you,

John
Jan 8 '07 #1
6 1332
Take a close look at what "myClass.myDirectory + myClass.myFileName;" returns.

I bet you're not getting a valid filename or directory path out of it.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"xzzy" <mr********@comcast.netwrote in message
news:4J******************************@comcast.com. ..
>
In the follwoing code, myProcess.StartInfo.FileName is set to a valid path: c:\\hello.doc

The code produces the following error message: "%1 is not a valid Win32 application"

For c:\\hello.doc, I would expect the following code to open a Word document in a normal window.
//code++++++++++++++++++++++++++++++++
Process myProcess = new Process();

try
{
LinkButton btnClicked = (LinkButton)sender;
int myID = 1;
myClass.GetByID(myID);
myProcess.StartInfo.FileName = myClass.myDirectory + myClass.myFileName;
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
myProcess.StartInfo.CreateNoWindow = false;
myProcess.Start();
}

catch (Exception ex)
{

//end code++++++++++++++++++++++++++++++++

Thank you,

John

Jan 9 '07 #2
asp.net because its a service and does not have access to the desktop,
can not start a window app only a command line.

if you want to start word (which is not recommanded), you need to use
the automation api.

-- bruce (sqlwork.com)

xzzy wrote:
In the follwoing code, myProcess.StartInfo.FileName is set to a valid path:
c:\\hello.doc

The code produces the following error message: "%1 is not a valid Win32
application"

For c:\\hello.doc, I would expect the following code to open a Word document
in a normal window.
//code++++++++++++++++++++++++++++++++
Process myProcess = new Process();

try
{
LinkButton btnClicked = (LinkButton)sender;
int myID = 1;
myClass.GetByID(myID);
myProcess.StartInfo.FileName = myClass.myDirectory + myClass.myFileName;
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.WindowStyle =
System.Diagnostics.ProcessWindowStyle.Normal;
myProcess.StartInfo.CreateNoWindow = false;
myProcess.Start();
}

catch (Exception ex)
{

//end code++++++++++++++++++++++++++++++++

Thank you,

John

Jan 9 '07 #3
"xzzy" <mr********@comcast.netwrote in message
news:4J******************************@comcast.com. ..
In the follwoing code, myProcess.StartInfo.FileName is set to a valid
path: c:\\hello.doc

The code produces the following error message: "%1 is not a valid Win32
application"

For c:\\hello.doc, I would expect the following code to open a Word
document in a normal window.
But how could it possibly do that...?

ASP.NET runs on the server, not on the client...

ASP.NET (principally) receives HttpRequests from web browsers and responds
by streaming HTML back down to the web browser...

Your code will do the following:

1) create a new Process object on the webserver

2) look for the installed application which corresponds to the supplied
filename's extension - in this case, .doc

3) try to instantiate that application and run it in the Process object - on
the server, not on the client.

ASP.NET can't open browser windows - it needs to create client-side markup
(hyperlinks or JavaScript) to do that...
Jan 9 '07 #4
Are you trying to open a Word document on the user's computer?
If so, you're going about it the wrong way.
There are several ways to open a Word doc on the client, the simplest would
be this:
Response.Redirect("/PublicDir/MyWordDoc.doc")

Here's more info:
http://msdn.microsoft.com/library/de...FileTopic1.asp
http://SteveOrr.net/articles/ExportPanel.aspx
http://SteveOrr.net/reviews/AsposeWord.aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"xzzy" <mr********@comcast.netwrote in message
news:4J******************************@comcast.com. ..
>
In the follwoing code, myProcess.StartInfo.FileName is set to a valid
path: c:\\hello.doc

The code produces the following error message: "%1 is not a valid Win32
application"

For c:\\hello.doc, I would expect the following code to open a Word
document in a normal window.
//code++++++++++++++++++++++++++++++++
Process myProcess = new Process();

try
{
LinkButton btnClicked = (LinkButton)sender;
int myID = 1;
myClass.GetByID(myID);
myProcess.StartInfo.FileName = myClass.myDirectory +
myClass.myFileName;
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.WindowStyle =
System.Diagnostics.ProcessWindowStyle.Normal;
myProcess.StartInfo.CreateNoWindow = false;
myProcess.Start();
}

catch (Exception ex)
{

//end code++++++++++++++++++++++++++++++++

Thank you,

John
Jan 9 '07 #5
the value of

myClass.myDirectory + myClass.myFileName

is

c:\\hello.doc

which is a file located on the server upon which asp.net is being served
from ( in other words, it's not on the client )
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Take a close look at what "myClass.myDirectory + myClass.myFileName;"
returns.

I bet you're not getting a valid filename or directory path out of it.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"xzzy" <mr********@comcast.netwrote in message
news:4J******************************@comcast.com. ..
>>
In the follwoing code, myProcess.StartInfo.FileName is set to a valid
path: c:\\hello.doc

The code produces the following error message: "%1 is not a valid Win32
application"

For c:\\hello.doc, I would expect the following code to open a Word
document in a normal window.
//code++++++++++++++++++++++++++++++++
Process myProcess = new Process();

try
{
LinkButton btnClicked = (LinkButton)sender;
int myID = 1;
myClass.GetByID(myID);
myProcess.StartInfo.FileName = myClass.myDirectory +
myClass.myFileName;
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.WindowStyle =
System.Diagnostics.ProcessWindowStyle.Normal;
myProcess.StartInfo.CreateNoWindow = false;
myProcess.Start();
}

catch (Exception ex)
{

//end code++++++++++++++++++++++++++++++++

Thank you,

John


Jan 9 '07 #6
On Mon, 08 Jan 2007 17:38:02 -0800, bruce barker wrote:
asp.net because its a service and does not have access to the desktop,
can not start a window app only a command line.
Actually you can -- only it won't be visible. Give it a shot. Try and start
notepad then check in task manager

--
Bits.Bytes
http://bytes.thinkersroom.com
Jan 10 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ilya Dubov | last post by:
I am starting "iexplore" process by executing Process.Start command. Every time I execute this command, it creates a new window. Can somebody tell me what can I do, so that the new window...
12
by: serge calderara | last post by:
Dear all, I have an application which is suppose to start another executable process. As soon as that process is running, I need to retrive its handle. The problem of the particular process I am...
3
by: Timothy Shih | last post by:
Hi, I am trying to start a process from inside a .NET service. The process is a simple GUI app, the service will start up the GUI and then stop itself. The service starts the app, but no GUI...
3
by: BCM | last post by:
In a simple console app the following few lines open up an Acrobat file without a hitch: Process p = new Process(); p.StartInfo.FileName = @"C:\test.pdf"; p.Start(); But the same code in an...
3
by: Christopher | last post by:
One of our ASP.NET Pages is starting a new Process using the Process object. When the process starts, it is started under the ASPNET User. We tried editing the web.config file and the...
1
by: Frank | last post by:
Hi, I use the standard example to start a program: Private Sub StartWithArguments() ' Declare and instantiate a new process component. Dim myproc As System.Diagnostics.Process myproc = New...
2
by: mwazir | last post by:
Hi all, I have a process thats starts in my application and only terminates when my application is terminated. I want to write the output and the errors of this process to a seperate log file....
4
by: Paul | last post by:
Hi, I am trying to start a process hidden. My code: wordprocess = new System.Diagnostics.Process(); ; wordprocess.StartInfo = new System.Diagnostics.ProcessStartInfo(wcmd, args);...
5
by: Reddy | last post by:
I am running process.sart to run gpg.exe to encrypt files. It's working fine with console application. When i use same code in windows service. It's not working. It's not even throwing...
11
by: garyusenet | last post by:
For this first time today I used the System.Diagnositcs namespace to launch a program from my c# code. The program launches OK but I have something which has completely stumped me. The...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.