473,326 Members | 2,127 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,326 software developers and data experts.

Starting Windows Service from ASP.NET

Hi,

I need to start some Windows Service from ASP.NET.
I use Process class of Framework.

/************************************************** */
System.Diagnostics.Process p=new System.Diagnostics.Process();
p.StartInfo.FileName="NET"; // Run NET command
p.StartInfo.Arguments="START MyService"; //Parameters
p.StartInfo.UseShellExecute=false;
p.StartInfo.RedirectStandardError=true;
p.Start();
string errstream=p.StandardError.ReadToEnd(); // Catch the output of process
p.WaitForExit();
/************************************************** */

After running this code errstream contains:
System error 5 occured
Access denied.

This behavior I get only when I try to start service - other NET commands
like HELP for example executed correctly.

I granted permission of administrator to ASPNET account, but It did't help.

What is a problem?
Jul 21 '05 #1
1 2340
Hi

Try using the System.ServiceProcess.ServiceController class

Gary
"Evgeny Cherny" <ch****@012.net.il> wrote in message
news:On**************@tk2msftngp13.phx.gbl...
Hi,

I need to start some Windows Service from ASP.NET.
I use Process class of Framework.

/************************************************** */
System.Diagnostics.Process p=new System.Diagnostics.Process();
p.StartInfo.FileName="NET"; // Run NET command
p.StartInfo.Arguments="START MyService"; //Parameters
p.StartInfo.UseShellExecute=false;
p.StartInfo.RedirectStandardError=true;
p.Start();
string errstream=p.StandardError.ReadToEnd(); // Catch the output of process p.WaitForExit();
/************************************************** */

After running this code errstream contains:
System error 5 occured
Access denied.

This behavior I get only when I try to start service - other NET commands
like HELP for example executed correctly.

I granted permission of administrator to ASPNET account, but It did't help.
What is a problem?

Jul 21 '05 #2

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

Similar topics

1
by: Glenn | last post by:
I have used this code successfully in a form application. I tried to add the same code in a service and have not been able to get the application to start. I have the service starting with a local...
2
by: karl | last post by:
I have a windows service that kicks off a 'monitor' thread which in turn kicks off 4 additional threads. These 4 threads basically are listen on a designated socket and report back any errors...
2
by: Razzie | last post by:
Hey all, I wrote a Windows Service. When I test it on my developement machine (winXP) it works fine. It starts ok, never crashes, etc. When I install the service on another machine (win2000) it...
4
by: Kristof Despiere | last post by:
Suppose you have one domain, filled with a couple of users. What needs to be done now is I need to start a windows application from a webform by pressing a button on the webform (for example). ...
0
by: tshad | last post by:
I have a Windows Service I created that just sets a timer and writes to EventLog every 10 seconds. It installed fine and it actually starts. But it says it doesn't. The progress bar shows the...
4
by: hogcods | last post by:
I'm having a strange problem with a service I developed. After installing the service on the target machine, I'm trying to start it using the Services admin window. I get the "Windows is starting"...
3
by: Johnny Fugazzi | last post by:
OK, I created my handy little windows service and created an MSI installer using the Deployment tool in VS.net with Custom Actions according to the msdn help. Worked great, with one little...
6
by: Arnie | last post by:
We're using the ServiceController class provided by the .NET Framework, programming in C#. We are using the Start() method to start a service from another service. This works fine most of the...
5
by: Benzi Eilon | last post by:
I have written a C# application which should run as a Windows Service. I must avoid having multiple instances of the application on one machine so I inserted the following code at the beginning of...
5
by: eliasen | last post by:
Hi I have created a Windows Service using C# and .NET2.0. The service is quite simple - right now it doesn't do anything except throwing an exception in the OnStart method. It used to something...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.