473,396 Members | 1,938 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,396 software developers and data experts.

Process.Start() in Web Service

Im writing a web service to return the ouput from a console app running on
the server but I can't get it to work. Nothing happens it seems ... The code
looks like this:

[WebMethod()]
public string GetSvnLog(string path, long from, long to)
{
ProcessStartInfo info = new ProcessStartInfo("svn", String.Format("log
{0} --xml --revision {1}:{2}", path, from, to));
info.UseShellExecute = false;
info.CreateNoWindow = true;
info.RedirectStandardOutput = true;
info.StandardOutputEncoding = System.Text.Encoding.UTF8;

Process p = new Process();
p.StartInfo = info;

try
{
p.Start();
return p.StandardOutput.ReadToEnd();
}
catch
{
return null;
}
finally
{
p.Close();
}
}

I assume it is a permission issue but I have no clue how to set the
permissions if it is possible even?

I have set "Execute permissions" to "Scripts and Executables" in the IISM
but that didnt seem to help...

I have tried enabling impersonation in the Web.config and set the user to an
existing user on the server but that only resultet in an error that I didnt
have write permissions to the ASP.NET temp-folder. I then added these
permissions with cacls but then it was the Network Services account that
didnt have the permissions insted...

I have tried setting UserName and Password properties of the
ProcessStartInfo but that didnt do much at all ...

I have searched and searched the web but couldnt find a solution anywhere...

First of all ... is it possible at all to execute a consoleapp in a web
service and have the output returned as a string?

can anyone steer me in the right direction or provide an example of how this
could be accomplished?
Sep 21 '07 #1
2 1875
"Maximilian" <Ma********@discussions.microsoft.comwrote in message
news:16**********************************@microsof t.com...

You should start by looking at the exception you're ignoring in your catch
block.

You should almost _never_ use "catch" without an exception.
--
--------------------------------------------------------------------------------
John Saunders | MVP – Windows Server System – Connected System Developer

Sep 21 '07 #2
in your catch, you should always do something with the exception, never
suppress it like that, especially if you're catching everything.

"Maximilian" <Ma********@discussions.microsoft.comwrote in message
news:16**********************************@microsof t.com...
Im writing a web service to return the ouput from a console app running on
the server but I can't get it to work. Nothing happens it seems ... The
code
looks like this:

[WebMethod()]
public string GetSvnLog(string path, long from, long to)
{
ProcessStartInfo info = new ProcessStartInfo("svn", String.Format("log
{0} --xml --revision {1}:{2}", path, from, to));
info.UseShellExecute = false;
info.CreateNoWindow = true;
info.RedirectStandardOutput = true;
info.StandardOutputEncoding = System.Text.Encoding.UTF8;

Process p = new Process();
p.StartInfo = info;

try
{
p.Start();
return p.StandardOutput.ReadToEnd();
}
catch
{
return null;
}
finally
{
p.Close();
}
}

I assume it is a permission issue but I have no clue how to set the
permissions if it is possible even?

I have set "Execute permissions" to "Scripts and Executables" in the IISM
but that didnt seem to help...

I have tried enabling impersonation in the Web.config and set the user to
an
existing user on the server but that only resultet in an error that I
didnt
have write permissions to the ASP.NET temp-folder. I then added these
permissions with cacls but then it was the Network Services account that
didnt have the permissions insted...

I have tried setting UserName and Password properties of the
ProcessStartInfo but that didnt do much at all ...

I have searched and searched the web but couldnt find a solution
anywhere...

First of all ... is it possible at all to execute a consoleapp in a web
service and have the output returned as a string?

can anyone steer me in the right direction or provide an example of how
this
could be accomplished?

Sep 25 '07 #3

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

Similar topics

6
by: Dmitri Shvetsov | last post by:
Hi, Can I start an external process from the Web Service? I'm using a code, compiler keeps silence, compiles ok and starts the project. When I trace in Debugger it doesn't start an external...
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...
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...
3
by: SugarDaddy | last post by:
Here's my problem. I have an NT service (really a .NET service) running as local system. I have a .NET form running on the user account. The form and the service communicate via an IPC Channel...
4
by: Steven De Smet | last post by:
Hello, This is my first post. I searched on the internet for answers but I was unable to solve my problem. So I hope that you guy's can help me with my VB.NET problem I tried to create a...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.