Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is it possible to run a console application on windows, and have it continue after user logs out?

3 views
Skip to first unread message

anywhe...@gmail.com

unread,
Nov 18, 2006, 8:47:10 PM11/18/06
to
It seems that if a service starts up a console application, than after
the user who was logged in logs out, the service continues to run, but
the console application shuts down. Is there a way to keep that
console application running after the user logs out? Since the service
continues to run, I hope the answer is yes.

In terms of technical details, the service is actually calling a perl
user exit, and that user exit starts up the console program we want to
continue running by doing: system("cmd /c start /b "" java ...");.
The call to 'cmd' is necessary, because mks has 'start' (and
if you don't say 'cmd', than mks's start seems to execute), but I want
to execute dos's start command. The command start /b means create a
new process without creating a dos window. The double quotes are the
title of the window we are creating (even though /b means to create
one), and java ... is the process I am running, it's a java process
with lots of arguments - that's the console program I want to
continue running past the user logging out.

Any help is appreciated.
Thanks
Alex

Markus Schaaf

unread,
Nov 21, 2006, 1:45:46 AM11/21/06
to
<anywhe...@gmail.com> wrote:

> It seems that if a service starts up a console application, than after
> the user who was logged in logs out, the service continues to run, but
> the console application shuts down. Is there a way to keep that
> console application running after the user logs out? Since the service
> continues to run, I hope the answer is yes.

It depends on the 'windowstation' the console is connected to.
If the console is connected to the windowstation of the user
logging off, it is closed and the attached process dies.

anywhe...@gmail.com

unread,
Nov 21, 2006, 4:27:49 PM11/21/06
to

So how do I associate it with another, or no windowstation?

BTW, I tried using CreateProcessAsUser, like so:
ret = CreateProcessAsUser(hToken, NULL, argv[1], NULL, NULL,
TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi);
(argv[1] is usually 'sleep 9000')

On windows 2000, if I run this process (sleep 9000), and I don't wait
for it to finish (my main.c with that CreateProcessAsUser exits without
waiting) than I can log out and log back in and the process 'sleep' is
still running, which is great.
But on 2003, the process goes away.

Please help.

Grzegorz Wróbel

unread,
Nov 21, 2006, 4:49:22 PM11/21/06
to

That's funny because I saw a thread, not so long ago, where someone was
being worried about the opposite - that the console window can stay
forever. You can search microsoft.public.win32.programmer.kernel for
"Immortal console window" thread.

--
Grzegorz Wróbel
http://www.4neurons.com/
677265676F727940346E6575726F6E732E636F6D

0 new messages