Board index » cppbuilder » How to keep a Process running after user logs off

How to keep a Process running after user logs off


2007-11-14 12:39:28 PM
cppbuilder22
Hi,
I have googled for asnwers to this question. One way seems to be to use
CreateProcessWithLogon.
I have attempted this in the following sequence
LogonUser(..)
Crea{*word*249}vironmentBlock(..)
GetUserProfileDirectory(..)
CreateProcessWithLogon(..)
CloseHandle(..) 's
This starts the process OK - Task Manager shows it belonging to the
alternate user. Logging off this session causes the process started as
the alternate user to close also.
Am I heading in the right direction ?
Any Missing steps ?
Other clues ?
thanks
Paul
 
 

Re:How to keep a Process running after user logs off

"Paul" < XXXX@XXXXX.COM >wrote in message
Quote
Am I heading in the right direction ?
No. To have a process running without a user logged in, you need to write a
service application instead.
Gambit
 

Re:How to keep a Process running after user logs off

Remy Lebeau (TeamB) wrote:
Quote

"Paul" < XXXX@XXXXX.COM >wrote in message
news:473a8a10$ XXXX@XXXXX.COM ...

>Am I heading in the right direction ?

No. To have a process running without a user logged in, you need to
write a service application instead.

Having explored this some more it appears to be possible in Win XP at
least.
1. For example
www.ifdef.com/support/kb_article.asp&
indicates they have a solution? For a $6K product I hope the would!
2. I have a process (BCB6 Application) that simply logs to a file every
5 seconds.
User1 and User2 have sysadmin rights. If I use the Windows scheduler to
start this process at system start up as user1. I then log on as User2
- I can see the log entries incrementing. I then log off for a period
and then log back on as User2. The log does not contain any gaps which
seems to indicate that the process kept running while User 2 was logged
off.
The problem I have with this is that the process is not visible either
logging on as User1 or User2. I'm still working on this problem and any
help would be much appreciated.
thanks
Paul
--
 

{smallsort}

Re:How to keep a Process running after user logs off

Quote
2. I have a process (BCB6 Application) that simply logs to a file every
5 seconds.

User1 and User2 have sysadmin rights. If I use the Windows scheduler to
start this process at system start up as user1.
I.e. it runs under the local system account, like a service application
would.
Quote
The problem I have with this is that the process is not visible either
logging on as User1 or User2. I'm still working on this problem and any
help would be much appreciated.
Desktop interation is documented for service applications.
You are still heading in the wrong direction. Write a service application
instead and be done with it.
Leo Havm°ller.
 

Re:How to keep a Process running after user logs off

Leo Havm°ller wrote:
Quote
You are still heading in the wrong direction. Write a service application
instead and be done with it.
Then, if you need to be interactive, write another app that interfaces
with the service and the user.
When the user logs off, the interactive app will terminate but
the service continues.
 

Re:How to keep a Process running after user logs off

Thanks for all the suggestions to use a service. Already have that in
place. Have been directed to do the same with an Application :-(
thanks
Paul
--
 

Re:How to keep a Process running after user logs off

An interesting followup - at least to me :-)
Using psexec - part of pstools - psTest.exe is a Builder6 app with a
main form and nothing else.
Running on XP pro - One user loged on as administrator
psexec -i -d -s C:\Dev\LogOff\psTest.exe
psexec -i -d -s C:\Windows\notepad.exe
logoff
logon
Notepad survives - would be interesting to know how it does this?
cheers
Paul