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

Executing an application inside a Service

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;
proc.StartInfo.FileName="calc";
proc.Start();
/**************Executing a Process code ends here**************/

the above code is not working.......what is the other alternative or is my
approach wrong??...

with regards,
C.C.Chakkaradeep
Nov 16 '05 #1
15 2103
Chakkaradeep,

What's happening when you run it? Running another program from inside a
service isn't the best idea in the world, especially if it has a UI. If it
has a UI, then you have to let the service interact with the desktop, and
even then, you can't guarantee that there will be a desktop session (there
is none if no one is logged in).

What are you trying to do?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:D4**********************************@microsof t.com...
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;
proc.StartInfo.FileName="calc";
proc.Start();
/**************Executing a Process code ends here**************/

the above code is not working.......what is the other alternative or is my
approach wrong??...

with regards,
C.C.Chakkaradeep

Nov 16 '05 #2
Hi,

My Service is a Multithreaded Server which listens for connections at a
particular port....if any incoming connections come,the server accepts it and
starts an application with the parameter got from remote end by receiving the
informations from Socket....this is what i want to do...i have developed a
Multithreaded Server runnning as service,it is working fine by sending back
replies to clients....but am not able to execute an application....

so what is my next step??...am a newbie to Services...

with regards,
C.C.Chakkaradeep

"Nicholas Paldino [.NET/C# MVP]" wrote:
Chakkaradeep,

What's happening when you run it? Running another program from inside a
service isn't the best idea in the world, especially if it has a UI. If it
has a UI, then you have to let the service interact with the desktop, and
even then, you can't guarantee that there will be a desktop session (there
is none if no one is logged in).

What are you trying to do?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:D4**********************************@microsof t.com...
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;
proc.StartInfo.FileName="calc";
proc.Start();
/**************Executing a Process code ends here**************/

the above code is not working.......what is the other alternative or is my
approach wrong??...

with regards,
C.C.Chakkaradeep


Nov 16 '05 #3
As I told you before, services should not consider the presence of an
interactive destop, also, they should not spawn processes that have a UI
(he, they should not spawn processes at all).
By default services run in the context of a sandboxed desktop environment,
running a service in the context of the interactive desktop (enabling
"interact with desktop" in the Service properties) should ONLY be considered
for debugging purposes.

Willy.

"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:7D**********************************@microsof t.com...
Hi,

My Service is a Multithreaded Server which listens for connections at a
particular port....if any incoming connections come,the server accepts it
and
starts an application with the parameter got from remote end by receiving
the
informations from Socket....this is what i want to do...i have developed a
Multithreaded Server runnning as service,it is working fine by sending
back
replies to clients....but am not able to execute an application....

so what is my next step??...am a newbie to Services...

with regards,
C.C.Chakkaradeep

"Nicholas Paldino [.NET/C# MVP]" wrote:
Chakkaradeep,

What's happening when you run it? Running another program from
inside a
service isn't the best idea in the world, especially if it has a UI. If
it
has a UI, then you have to let the service interact with the desktop, and
even then, you can't guarantee that there will be a desktop session
(there
is none if no one is logged in).

What are you trying to do?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:D4**********************************@microsof t.com...
> 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;
> proc.StartInfo.FileName="calc";
> proc.Start();
> /**************Executing a Process code ends here**************/
>
> the above code is not working.......what is the other alternative or is
> my
> approach wrong??...
>
> with regards,
> C.C.Chakkaradeep


Nov 16 '05 #4
Chakkaradeep,

Does the account that the service is running under have the appropriate
permissions? Does the application you are running have a UI, or is it a
console app?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:7D**********************************@microsof t.com...
Hi,

My Service is a Multithreaded Server which listens for connections at a
particular port....if any incoming connections come,the server accepts it
and
starts an application with the parameter got from remote end by receiving
the
informations from Socket....this is what i want to do...i have developed a
Multithreaded Server runnning as service,it is working fine by sending
back
replies to clients....but am not able to execute an application....

so what is my next step??...am a newbie to Services...

with regards,
C.C.Chakkaradeep

"Nicholas Paldino [.NET/C# MVP]" wrote:
Chakkaradeep,

What's happening when you run it? Running another program from
inside a
service isn't the best idea in the world, especially if it has a UI. If
it
has a UI, then you have to let the service interact with the desktop, and
even then, you can't guarantee that there will be a desktop session
(there
is none if no one is logged in).

What are you trying to do?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:D4**********************************@microsof t.com...
> 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;
> proc.StartInfo.FileName="calc";
> proc.Start();
> /**************Executing a Process code ends here**************/
>
> the above code is not working.......what is the other alternative or is
> my
> approach wrong??...
>
> with regards,
> C.C.Chakkaradeep


Nov 16 '05 #5
Hi,

My application which to be made run by my Service is a GUI application say
"somename.exe",service has to just make it run....for this also i need to
spawn a thread???

with regards,
C.C.Chakkaradeep

"Nicholas Paldino [.NET/C# MVP]" wrote:
Chakkaradeep,

Does the account that the service is running under have the appropriate
permissions? Does the application you are running have a UI, or is it a
console app?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:7D**********************************@microsof t.com...
Hi,

My Service is a Multithreaded Server which listens for connections at a
particular port....if any incoming connections come,the server accepts it
and
starts an application with the parameter got from remote end by receiving
the
informations from Socket....this is what i want to do...i have developed a
Multithreaded Server runnning as service,it is working fine by sending
back
replies to clients....but am not able to execute an application....

so what is my next step??...am a newbie to Services...

with regards,
C.C.Chakkaradeep

"Nicholas Paldino [.NET/C# MVP]" wrote:
Chakkaradeep,

What's happening when you run it? Running another program from
inside a
service isn't the best idea in the world, especially if it has a UI. If
it
has a UI, then you have to let the service interact with the desktop, and
even then, you can't guarantee that there will be a desktop session
(there
is none if no one is logged in).

What are you trying to do?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:D4**********************************@microsof t.com...
> 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;
> proc.StartInfo.FileName="calc";
> proc.Start();
> /**************Executing a Process code ends here**************/
>
> the above code is not working.......what is the other alternative or is
> my
> approach wrong??...
>
> with regards,
> C.C.Chakkaradeep


Nov 16 '05 #6
Chakkaradeep,

In this case, you can't do this from a service. How are you going to
control the app from the service if it requires a UI? Also, the interaction
with the desktop is an issue as well. I would find another way to do what
you are doing (perhaps accessing a library that performs the same
functionality).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:74**********************************@microsof t.com...
Hi,

My application which to be made run by my Service is a GUI application say
"somename.exe",service has to just make it run....for this also i need to
spawn a thread???

with regards,
C.C.Chakkaradeep

"Nicholas Paldino [.NET/C# MVP]" wrote:
Chakkaradeep,

Does the account that the service is running under have the
appropriate
permissions? Does the application you are running have a UI, or is it a
console app?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:7D**********************************@microsof t.com...
> Hi,
>
> My Service is a Multithreaded Server which listens for connections at a
> particular port....if any incoming connections come,the server accepts
> it
> and
> starts an application with the parameter got from remote end by
> receiving
> the
> informations from Socket....this is what i want to do...i have
> developed a
> Multithreaded Server runnning as service,it is working fine by sending
> back
> replies to clients....but am not able to execute an application....
>
> so what is my next step??...am a newbie to Services...
>
> with regards,
> C.C.Chakkaradeep
>
> "Nicholas Paldino [.NET/C# MVP]" wrote:
>
>> Chakkaradeep,
>>
>> What's happening when you run it? Running another program from
>> inside a
>> service isn't the best idea in the world, especially if it has a UI.
>> If
>> it
>> has a UI, then you have to let the service interact with the desktop,
>> and
>> even then, you can't guarantee that there will be a desktop session
>> (there
>> is none if no one is logged in).
>>
>> What are you trying to do?
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mv*@spam.guard.caspershouse.com
>>
>> "Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in
>> message
>> news:D4**********************************@microsof t.com...
>> > 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;
>> > proc.StartInfo.FileName="calc";
>> > proc.Start();
>> > /**************Executing a Process code ends here**************/
>> >
>> > the above code is not working.......what is the other alternative or
>> > is
>> > my
>> > approach wrong??...
>> >
>> > with regards,
>> > C.C.Chakkaradeep
>>
>>
>>


Nov 16 '05 #7
Hi,

sorry friends,i forgot to add someting IMPORTANT in previous post...i opened
up my Task Manager and found instances of "calc.exe" running which was
started by my Service...but GUI has not shown ???......

this service is important for me becoz am monitoring a port regularly and
have to start my client application as and when i get request....

there is no means that we can start an application using Services???...if
there is,then can anyone tell me code for that or link??

with regards,
C.C.Chakkaradeep

"Chakkaradeep" wrote:
Hi,

My application which to be made run by my Service is a GUI application say
"somename.exe",service has to just make it run....for this also i need to
spawn a thread???

with regards,
C.C.Chakkaradeep

"Nicholas Paldino [.NET/C# MVP]" wrote:
Chakkaradeep,

Does the account that the service is running under have the appropriate
permissions? Does the application you are running have a UI, or is it a
console app?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:7D**********************************@microsof t.com...
Hi,

My Service is a Multithreaded Server which listens for connections at a
particular port....if any incoming connections come,the server accepts it
and
starts an application with the parameter got from remote end by receiving
the
informations from Socket....this is what i want to do...i have developed a
Multithreaded Server runnning as service,it is working fine by sending
back
replies to clients....but am not able to execute an application....

so what is my next step??...am a newbie to Services...

with regards,
C.C.Chakkaradeep

"Nicholas Paldino [.NET/C# MVP]" wrote:

> Chakkaradeep,
>
> What's happening when you run it? Running another program from
> inside a
> service isn't the best idea in the world, especially if it has a UI. If
> it
> has a UI, then you have to let the service interact with the desktop, and
> even then, you can't guarantee that there will be a desktop session
> (there
> is none if no one is logged in).
>
> What are you trying to do?
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - mv*@spam.guard.caspershouse.com
>
> "Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
> news:D4**********************************@microsof t.com...
> > 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;
> > proc.StartInfo.FileName="calc";
> > proc.Start();
> > /**************Executing a Process code ends here**************/
> >
> > the above code is not working.......what is the other alternative or is
> > my
> > approach wrong??...
> >
> > with regards,
> > C.C.Chakkaradeep
>
>
>


Nov 16 '05 #8

"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:93**********************************@microsof t.com...
Hi,

sorry friends,i forgot to add someting IMPORTANT in previous post...i
opened
*** We added also IMPORTANT things in our replies my friend ;-). But I guess
something wasn't very clear.
up my Task Manager and found instances of "calc.exe" running which was
started by my Service...but GUI has not shown ???......
*** Because the service run in a non visible desktop! As a result all
process spawned from this service will run in an invisible desktop!
this service is important for me becoz am monitoring a port regularly and
have to start my client application as and when i get request....

there is no means that we can start an application using Services???...if
there is,then can anyone tell me code for that or link??

*** No, you can't, just run this as a normal desktop application, just start
it from a logon script if you need to have it running all the time there is
a user logged-on.

Willy.
Nov 16 '05 #9
One of these days I'll have to go through and test this so I can stop
talking theory, but for now here is what I have heard and believe will
work "in theory:"

You should be able to go into the service mmc snap-in and set the
properties of the service and set it to allow the service to interact
with the desktop. You'll obviously want to test this to see if it works
but I think it is sound, however as others have mentioned this setting
will only work (if at all) if someone is actively logged on to the system.

If you don't mind some design advice, I would recommend that you split
this into two different applications. One a service that listens for
connections and another that gets started when a user logs on to the
desktop. The startup application would register with the service to be
passed notification that the "calc.exe" application should be started
and then the startup application would run "calc.exe". This would allow
you to have the functionality that you are looking for, not be worried
about whether or not a service can run something on the desktop, and
allow remote workstations to register and receive the same kinds of
messages/application startups as the local system. Just a thought.

Have A Better One!

John M Deal, MCP
Necessity Software

P.S. Please let me/us know if you decide to try the interactive desktop
option and whether or not it works.

Chakkaradeep wrote:
Hi,

sorry friends,i forgot to add someting IMPORTANT in previous post...i opened
up my Task Manager and found instances of "calc.exe" running which was
started by my Service...but GUI has not shown ???......

this service is important for me becoz am monitoring a port regularly and
have to start my client application as and when i get request....

there is no means that we can start an application using Services???...if
there is,then can anyone tell me code for that or link??

with regards,
C.C.Chakkaradeep

"Chakkaradeep" wrote:

Hi,

My application which to be made run by my Service is a GUI application say
"somename.exe",service has to just make it run....for this also i need to
spawn a thread???

with regards,
C.C.Chakkaradeep

"Nicholas Paldino [.NET/C# MVP]" wrote:

Chakkaradeep,

Does the account that the service is running under have the appropriate
permissions? Does the application you are running have a UI, or is it a
console app?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:7D**********************************@micro soft.com...

Hi,

My Service is a Multithreaded Server which listens for connections at a
particular port....if any incoming connections come,the server accepts it
and
starts an application with the parameter got from remote end by receiving
the
informations from Socket....this is what i want to do...i have developed a
Multithreaded Server runnning as service,it is working fine by sending
back
replies to clients....but am not able to execute an application....

so what is my next step??...am a newbie to Services...

with regards,
C.C.Chakkaradeep

"Nicholas Paldino [.NET/C# MVP]" wrote:
>Chakkaradeep,
>
> What's happening when you run it? Running another program from
>inside a
>service isn't the best idea in the world, especially if it has a UI. If
>it
>has a UI, then you have to let the service interact with the desktop, and
>even then, you can't guarantee that there will be a desktop session
>(there
>is none if no one is logged in).
>
> What are you trying to do?
>
>
>--
> - Nicholas Paldino [.NET/C# MVP]
> - mv*@spam.guard.caspershouse.com
>
>"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
>news:D4**********************************@mic rosoft.com...
>
>>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;
>>proc.StartInfo.FileName="calc";
>>proc.Start();
>>/**************Executing a Process code ends here**************/
>>
>>the above code is not working.......what is the other alternative or is
>>my
>>approach wrong??...
>>
>>with regards,
>>C.C.Chakkaradeep
>
>
>

Nov 16 '05 #10
Hi,

hey i can see in Windows Task Manager , the process i started in my service
running..but i cant see the GUI part..........i think this is done in VB.NET
Service,becoz i saw in forum that a person implementing it in VB.NET...that
person asked for the same thing what i had asked and the error was
correctd..the error was putting the full path name n the FileName startinfo
parameter...

i cant really belive u Willy,Windows restricting an execution of another
application??...then whats the use of having services run in
background???....there should be some way......

how wil u access desktop in services??

with regards,
C.C.Chakkaradeep

"Willy Denoyette [MVP]" wrote:

"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:93**********************************@microsof t.com...
Hi,

sorry friends,i forgot to add someting IMPORTANT in previous post...i
opened


*** We added also IMPORTANT things in our replies my friend ;-). But I guess
something wasn't very clear.
up my Task Manager and found instances of "calc.exe" running which was
started by my Service...but GUI has not shown ???......

*** Because the service run in a non visible desktop! As a result all
process spawned from this service will run in an invisible desktop!
this service is important for me becoz am monitoring a port regularly and
have to start my client application as and when i get request....

there is no means that we can start an application using Services???...if
there is,then can anyone tell me code for that or link??

*** No, you can't, just run this as a normal desktop application, just start
it from a logon script if you need to have it running all the time there is
a user logged-on.

Willy.

Nov 16 '05 #11
Chakkaradeep,

That's the thing, you don't (or at least, you should not, with an
emphasis on SHOULD NOT).

Rather, if you have a need to do something in the desktop from a
service, then the desktop application should make a request to the service
through remoting.

However, this isn't what you are doing, you want to run an application
to perform calculations. You shouldn't do it if it pops up a UI.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:74**********************************@microsof t.com...
Hi,

hey i can see in Windows Task Manager , the process i started in my
service
running..but i cant see the GUI part..........i think this is done in
VB.NET
Service,becoz i saw in forum that a person implementing it in
VB.NET...that
person asked for the same thing what i had asked and the error was
correctd..the error was putting the full path name n the FileName
startinfo
parameter...

i cant really belive u Willy,Windows restricting an execution of another
application??...then whats the use of having services run in
background???....there should be some way......

how wil u access desktop in services??

with regards,
C.C.Chakkaradeep

"Willy Denoyette [MVP]" wrote:

"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:93**********************************@microsof t.com...
> Hi,
>
> sorry friends,i forgot to add someting IMPORTANT in previous post...i
> opened


*** We added also IMPORTANT things in our replies my friend ;-). But I
guess
something wasn't very clear.
> up my Task Manager and found instances of "calc.exe" running which was
> started by my Service...but GUI has not shown ???......
>

*** Because the service run in a non visible desktop! As a result all
process spawned from this service will run in an invisible desktop!
> this service is important for me becoz am monitoring a port regularly
> and
> have to start my client application as and when i get request....
>
> there is no means that we can start an application using
> Services???...if
> there is,then can anyone tell me code for that or link??

*** No, you can't, just run this as a normal desktop application, just
start
it from a logon script if you need to have it running all the time there
is
a user logged-on.

Willy.

Nov 16 '05 #12
hi all,

check out this link,this article shows how to run applications using NT
Service written in C,so when it can be done there why cant it be done in
C#???....

http://www.codeproject.com/system/xyntservice.asp

with regards,
C.C.Chakkaradeep
"John M Deal" wrote:
One of these days I'll have to go through and test this so I can stop
talking theory, but for now here is what I have heard and believe will
work "in theory:"

You should be able to go into the service mmc snap-in and set the
properties of the service and set it to allow the service to interact
with the desktop. You'll obviously want to test this to see if it works
but I think it is sound, however as others have mentioned this setting
will only work (if at all) if someone is actively logged on to the system.

If you don't mind some design advice, I would recommend that you split
this into two different applications. One a service that listens for
connections and another that gets started when a user logs on to the
desktop. The startup application would register with the service to be
passed notification that the "calc.exe" application should be started
and then the startup application would run "calc.exe". This would allow
you to have the functionality that you are looking for, not be worried
about whether or not a service can run something on the desktop, and
allow remote workstations to register and receive the same kinds of
messages/application startups as the local system. Just a thought.

Have A Better One!

John M Deal, MCP
Necessity Software

P.S. Please let me/us know if you decide to try the interactive desktop
option and whether or not it works.

Chakkaradeep wrote:
Hi,

sorry friends,i forgot to add someting IMPORTANT in previous post...i opened
up my Task Manager and found instances of "calc.exe" running which was
started by my Service...but GUI has not shown ???......

this service is important for me becoz am monitoring a port regularly and
have to start my client application as and when i get request....

there is no means that we can start an application using Services???...if
there is,then can anyone tell me code for that or link??

with regards,
C.C.Chakkaradeep

"Chakkaradeep" wrote:

Hi,

My application which to be made run by my Service is a GUI application say
"somename.exe",service has to just make it run....for this also i need to
spawn a thread???

with regards,
C.C.Chakkaradeep

"Nicholas Paldino [.NET/C# MVP]" wrote:
Chakkaradeep,

Does the account that the service is running under have the appropriate
permissions? Does the application you are running have a UI, or is it a
console app?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:7D**********************************@micro soft.com...

>Hi,
>
>My Service is a Multithreaded Server which listens for connections at a
>particular port....if any incoming connections come,the server accepts it
>and
>starts an application with the parameter got from remote end by receiving
>the
>informations from Socket....this is what i want to do...i have developed a
>Multithreaded Server runnning as service,it is working fine by sending
>back
>replies to clients....but am not able to execute an application....
>
>so what is my next step??...am a newbie to Services...
>
>with regards,
>C.C.Chakkaradeep
>
>"Nicholas Paldino [.NET/C# MVP]" wrote:
>
>
>>Chakkaradeep,
>>
>> What's happening when you run it? Running another program from
>>inside a
>>service isn't the best idea in the world, especially if it has a UI. If
>>it
>>has a UI, then you have to let the service interact with the desktop, and
>>even then, you can't guarantee that there will be a desktop session
>>(there
>>is none if no one is logged in).
>>
>> What are you trying to do?
>>
>>
>>--
>> - Nicholas Paldino [.NET/C# MVP]
>> - mv*@spam.guard.caspershouse.com
>>
>>"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
>>news:D4**********************************@mic rosoft.com...
>>
>>>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;
>>>proc.StartInfo.FileName="calc";
>>>proc.Start();
>>>/**************Executing a Process code ends here**************/
>>>
>>>the above code is not working.......what is the other alternative or is
>>>my
>>>approach wrong??...
>>>
>>>with regards,
>>>C.C.Chakkaradeep
>>
>>
>>

Nov 16 '05 #13

"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:74**********************************@microsof t.com...
Hi,

hey i can see in Windows Task Manager , the process i started in my
service
running..but i cant see the GUI part..........i think this is done in
VB.NET
Service,becoz i saw in forum that a person implementing it in
VB.NET...that
person asked for the same thing what i had asked and the error was
correctd..the error was putting the full path name n the FileName
startinfo
parameter...

i cant really belive u Willy,Windows restricting an execution of another
application??...then whats the use of having services run in
background???....there should be some way......


Do you actually read what I'm writing? I told you, that:
- you can make your Service interact with the desktop, you can set "Interact
with desktop" if your service runs under the SYSTEM pseudo account using the
Services Control applet. But again you should NOT do this unless you are
debugging and even then I would suggest you don't, there are better options
to debug a service.
- Services are meant to run when no-one is logged on to the system, so when
there is no active desktop available, take a look at the services actually
running on your system, do they interact with the desktop? NO they don't.
- Services don't have access to a users profile either, just because they
are meant to run when no such profile is loaded.

But you don't have to believe me, if you prefer to find out yourself the
hard way.

Willy.
Nov 16 '05 #14


"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:74**********************************@microsof t.com...
hi all,

check out this link,this article shows how to run applications using NT
Service written in C,so when it can be done there why cant it be done in
C#???....


No, you should read this article, it clearly states:

<snip
a.. It can start as many programs as you want. The started programs behave
like NT services (i.e. they will be running in the background without the
user having to login to the machine).

/snip>

"The started programs behave like services" - means they don't interact with
the desktop.

unless...... somewhat further...
<snip
The UserInterface property controls whether a logged on user can see the
processes created by XYNTService.However, this only works when XYNTService
is running under the local system account, which is the default.
/snip>

This means that the XYNTService service itself toggles the "Can interact
with the desktop" option I have mentioned several times.
Note that we didn't say it wasn't possible, just that running services with
this option enabled is bad practice and starting GUI programs from within
services makes it even worse.
Again we suggest you to revise your design such that you have a real nice
service running in the background, that uses some form of IPC to talk to
another Interactive program. Let the UI program start by the logon user, or
automatically when the user logs on. It's up to the service to know when the
UI is available.

Willy.
Willy.
Nov 16 '05 #15
Hi,

Willy, but is there a way to implement this in C#...becoz my work of
Multithreaded Server Service is completed already.......

???

with regards,
C.C.Chakkaradeep

"Willy Denoyette [MVP]" wrote:


"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:74**********************************@microsof t.com...
hi all,

check out this link,this article shows how to run applications using NT
Service written in C,so when it can be done there why cant it be done in
C#???....


No, you should read this article, it clearly states:

<snip
a.. It can start as many programs as you want. The started programs behave
like NT services (i.e. they will be running in the background without the
user having to login to the machine).

/snip>

"The started programs behave like services" - means they don't interact with
the desktop.

unless...... somewhat further...
<snip
The UserInterface property controls whether a logged on user can see the
processes created by XYNTService.However, this only works when XYNTService
is running under the local system account, which is the default.
/snip>

This means that the XYNTService service itself toggles the "Can interact
with the desktop" option I have mentioned several times.
Note that we didn't say it wasn't possible, just that running services with
this option enabled is bad practice and starting GUI programs from within
services makes it even worse.
Again we suggest you to revise your design such that you have a real nice
service running in the background, that uses some form of IPC to talk to
another Interactive program. Let the UI program start by the logon user, or
automatically when the user logs on. It's up to the service to know when the
UI is available.

Willy.
Willy.

Nov 16 '05 #16

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

Similar topics

13
by: BK | last post by:
Can someone point me to a code sample that illustrates executing long running tasks (asynchronous) from a web application in ASP.NET? I assume that Web Services might come into play at some point,...
1
by: Yoshitha | last post by:
HI I am calling exe (vb.net application) from web application for this i wrote code like this system.diagnosis.process.start("e:\...") i wrote above code in button click event.
3
by: Peter Strřiman | last post by:
Hi. I have a web application that needs to run tasks at regular intervals. E.g. it must send out emails every night to people who subscribe to that service. I have come up with one solution,...
0
by: Yoshitha | last post by:
HI I am calling exe (vb.net application) from web application for this i wrote code like this system.diagnosis.process.start("e:\...") i wrote above code in button click event.
7
by: tshad | last post by:
I thought I understood how the SaveViewState is working and was trying to use this (as per some code I found) to detect refreshes. It seemed to be working but I found that the SaveViewState was...
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
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: 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
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
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.