473,785 Members | 2,756 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

c# service unable to spawn exe

Hi Everyone

I have a problem with windows service I wrote which spawns a win32
program.
the code in question looks like this:

myProcess = new Process();
myProcess.Start Info.FileName = GetInstallPath( ) + "\\my.exe";
myProcess.Start Info.CreateNoWi ndow = false;
myProcess.Start ();

Some users (not all) get access denied immediately after calling start
on the process.

The service is installed to run under the local system account.

If the account is changed to run under the local user account there is
no problem.

This is perplexing cos surely the local system account has the highest
privileges.

Any ideas?

I should say the exe is local and not on mapped network drive.

Cheers

Richard

Oct 18 '06 #1
4 5713
Hello richie,

This problem is arised several times
See there http://groups.google.com/group/micro...4abb972698ae09

rHi Everyone
r>
rI have a problem with windows service I wrote which spawns a win32
rprogram.
rthe code in question looks like this:
rmyProcess = new Process();
rmyProcess.Star tInfo.FileName = GetInstallPath( ) + "\\my.exe";
rmyProcess.Star tInfo.CreateNoW indow = false;
rmyProcess.Star t();
rSome users (not all) get access denied immediately after calling
rstart on the process.
r>
rThe service is installed to run under the local system account.
r>
rIf the account is changed to run under the local user account there
ris no problem.
r>
rThis is perplexing cos surely the local system account has the
rhighest privileges.
r>
rAny ideas?
r>
rI should say the exe is local and not on mapped network drive.
r>
rCheers
r>
rRichard
r>
---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Oct 18 '06 #2

Thanks for the reply Michael

I also contacted Microsoft and they said:
>>>>>
System.Diagnost ics.Process.Sta rt is calling CreateProcessWi thLogonW API
under the scenes. The behavior of this API has changed in Windows XP
SP2 and Windows Server 2003:

CreateProcessWi thLogonW

http://msdn.microsoft.com/library/de...withlogonw.asp

"

Windows XP SP2 and Windows Server 2003: You cannot call
CreateProcessWi thLogonW from a process that is running under the
LocalSystem account, because the function uses the logon SID in the
caller token, and the token for the LocalSystem account does not
contain this SID. As an alternative, use the CreateProcessAs User and
LogonUser functions.

"

>>>>>
So basically starting a process from a c# service is not going to work
when running under the local system account, which I need to do cos
some users are restricted. I could use win32 via pinvoke to circumvent
this.

But I've decided to write the service in win32 and run the code as a
thread from the service. The exe I was running is c/c++ anyway so this
is easy.

If anyone is interested a good article for writing a win32 service is
http://www.commsoft.com/services.html

Thanks again

Cheers

Richard

Oct 19 '06 #3
Im a bit upset because I'm running a service under WinXP SP2 and the
following code works quite fine to spawn another process (in this case it's
the service executable itself started as an isolated worker process
communicating with the service by serializing commands using standard input
and output):

// Create startup information
ProcessStartInf o pStart = new
ProcessStartInf o(Application.E xecutablePath, "AsChild");

// Use standard I/O
pStart.UseShell Execute = false;
pStart.Redirect StandardOutput = true;
pStart.Redirect StandardInput = true;

// Create new process
Process pNew = new Process();

// Attach
pNew.StartInfo = pStart;

// Activate it
pNew.Start();

Actually you should rethink the CreateNoWindow = False - maybe at least the
interactive access to desktop would be required. But question is: do you
really start the process with a GUI?

Jochen

"richie" <ri************ *@hotmail.comwr ote in message
news:11******** **************@ m7g2000cwm.goog legroups.com...
>
Thanks for the reply Michael

I also contacted Microsoft and they said:
>>>>>>
System.Diagnost ics.Process.Sta rt is calling CreateProcessWi thLogonW API
under the scenes. The behavior of this API has changed in Windows XP
SP2 and Windows Server 2003:

CreateProcessWi thLogonW

http://msdn.microsoft.com/library/de...withlogonw.asp

"

Windows XP SP2 and Windows Server 2003: You cannot call
CreateProcessWi thLogonW from a process that is running under the
LocalSystem account, because the function uses the logon SID in the
caller token, and the token for the LocalSystem account does not
contain this SID. As an alternative, use the CreateProcessAs User and
LogonUser functions.

"

>>>>>>

So basically starting a process from a c# service is not going to work
when running under the local system account, which I need to do cos
some users are restricted. I could use win32 via pinvoke to circumvent
this.

But I've decided to write the service in win32 and run the code as a
thread from the service. The exe I was running is c/c++ anyway so this
is easy.

If anyone is interested a good article for writing a win32 service is
http://www.commsoft.com/services.html

Thanks again

Cheers

Richard

Oct 19 '06 #4
Hi Jochen

Thanks for the suggestion, my app has no gui. But I'll try it and let
you know.

I should point out that about 90% of our customers who installed the c#
service had no problems whatsoever. My problem is of course I need a
solution that works for all my customers.

I was really just being lazy cos I was just using the c# service as
thin wrapper.The win32 soln I've written creates a thread to run the
code I had previously in the exe. It took a morning to get it up and
running in win32 so not too much effort.

Not sure if any of that will make you feel better though.

Cheers

Richard

Oct 20 '06 #5

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

Similar topics

4
15895
by: Keith | last post by:
I'm in the same boat as the fellow who posted this message back in August: Title : Windows Service, How does one make a service "fail" properly? Author : Ross Bennett Group : microsoft.public.dotnet.languages.csharp URL :...
15
2146
by: Chakkaradeep | last post by:
Hi all, i have written a Service,now i want to execute another application (for eg;calc.exe) in the service....how will i perform it??... i tried using this.... /**************Executing a Process code starts here**************/ System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.EnableRaisingEvents=false;
9
7803
by: Adam Klobukowski | last post by:
Hello I've written a small C# program that uses VFPOLEDB it is working perfectly. Then, I redesigned it to work as service (as described in http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbwlkwalkthroughcreatingwindowsserviceapplication.asp). Unfortunetly, now my service is unable to use VFPOLEDB, stating that it "is not registered" on my local machine. Service is installed on LocalService account.
3
1625
by: Paul | last post by:
Hi all. Can someone provide some help on the following as there seems to be many different methods of acheiving the same outcome. Basically I am trying to develop a web service which will spawn an exe file to run an import and then return a result back to the web service, this would also need the facility to spawn multiple copies of the application upto a maximum figure..............
5
3258
by: Paul Hasell | last post by:
Hi, I'm trying to invoke a web method asynchronously but just can't seem to get it to tell me when it has finished! Below is the code I am (currently) using: private void btnUpload_Click(object sender, System.EventArgs e) { try { SOPWebService.Client uploader = new
3
1940
by: Rob R. Ainscough | last post by:
I have a Windows Service with a timer that use the .NET 2.0 Shell command. The Shell command returns a non-zero number but Task Manager shows the shelled exe running but there is NO visible interface (there should be one) -- I pass AppWinStyle.NormalFocus. If I execute the exact same in a Windows form test app, the Shell works flawlessly. I've tried Diagnostics.Process approach rather than Shell but have the same results -- my app...
8
1195
by: pigeonrandle | last post by:
Hi, I am writing a server application and would like to know what you experts think i should write it as. I would like (ie need) it to have a visual interface, hence the question, "Should i write it as a service and then provide another program that displays information on what's going on", or, "should i simply write it as a multi-threaded asynchronous socket beast GUI"?! I like the second option (mainly because it will involve less...
4
21756
by: carson | last post by:
I have written two windows services: - service A does some crunching of local data files and uploads them to a central processing computer via http. - service B monitors a manifest file on a webserver to see if service A needs to be updated. What service B does if it sees their is an update for service A is to download a new copy of the service A executable, stop service A, replace the executable with the new copy, and start service B...
7
2661
by: Laszlo Nagy | last post by:
Hello, I have a win32 service written in Python that starts a plain application, written in Python. The win32 service tries to launch the application in a while loop and logs the return value of the os.system call. That's all. The application is a simple Python program that connects to an https xml/rpc server, and works with the data retrieved from that server. It
0
9643
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10147
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10087
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9947
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8971
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.