Tech Support > Microsoft Windows > Development Resources > Can I stop the shutdown process? Can I make my computer never shutdown?
Can I stop the shutdown process? Can I make my computer never shutdown?
Posted by kiki on September 24th, 2005


Hi all,

I am using a Toshiba M4 Tablet PC and it has a nasty problem on its
standby. Every time I open the lid to resume from standby, it mysteriously
shutdown.

I tried to reinstall the OS and make it minimallly loaded in terms
memory/harddisk/battery... To make a long story short. In the past 25 days
I've fighted with its problems unrestedly and now I am tired.

It was good for a while. For quite a few days I
had only two mysterious shutdown. From this we can see this is a problem
with XP Tablet PC Version. I looked into the Internet but it seems that
there is no workaround in this XP version. Everybody seems to complain about
hibernation/standby problems everywhere. That's why I did not send it back.
The problem is on Windows side, what can I do? I need it for my work,
anyway...

At least before yesterday everything was acceptable to me.

But today I upgrade RAM to 1.5GB. Now these standby problems re-occur
frequently. It mysteriously shuts down all the time. 100% of time. There is
a known bug with XP Tablet PC version that it does not
do well in tablet PCs with 1.5GB RAM... I know that. There is no
workaround...

But I have to deal with my own problem: the mysteriously shutdown.

Every time when it resumes from standby, it mysteriously shutdown. This
basically makes "mobility" and "productivity" a far-away dream...

So I want to ask: how can I intervene the shutdown process and stop it from
happening? Can I have a computer that never shuts down?

If possible, can I program my own process that monitor the whole system and
make sure the shutdown process never works... ? Or can I create a die hard
dead process that the shutdown process does not work at all when it faces
the dead process?

Thanks a lot!




Posted by TC on September 24th, 2005


Multiposted AND crossposted! :-(

TC

Posted by kiki on September 24th, 2005


Yeah! I confess about that! Sorry But you know, they are all relevant groups
and on different servers... buddy!

Try to solve my problem! I have been mad about it...!

"TC" <aatcbbtccctc@yahoo.com> wrote in message
news:1127544571.754805.272280@z14g2000cwz.googlegr oups.com...


Posted by Scott en Aztlán on September 24th, 2005


On Sat, 24 Sep 2005 01:21:52 -0700, "kiki" <lunaliu3@yahoo.com> wrote:

AND top-posted.


Posted by Kellie Fitton on September 24th, 2005


Hi,

Try to handle the window message WM_QUERYENDSESSION, and make your
application returns zeros to stop ending the session.

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

Hope these information helps,

Kellie.

Posted by Boris on September 25th, 2005


"kiki" <lunaliu3@yahoo.com> wrote in message
news:dh2qht$ooo$1@news.Stanford.EDU...
after increasing RAM size to 1.5GB did you also increase pagefile size? If
not, try doing so: increase it to 2GB, for example. Also, make sure that MIN
and MAX values are both 2GB (meaning: 2GB of space for the pagefile are
actually allocated).

-Boris



Posted by Boris on September 25th, 2005


"kiki" <lunaliu3@yahoo.com> wrote in message
news:dh2qht$ooo$1@news.Stanford.EDU...
messages related to shutdown...maybe it will help to find reason why it
reboots (instead of just hibernating) - from OS standpoint.
To assess XP Logs go to Control Panel/Performance and
Maintenance/Administrative Tools/Event Viewer.

-Boris



Posted by kiki on September 25th, 2005


Please see bottom...

"Boris" <spamno@hello.com> wrote in message
news:qZuZe.189$Aw.3484@typhoon.sonic.net...


HI Boris,

Thanks a lot! I will try that out! But I was always using "standby" instead
of hibernation.



Posted by kiki on September 25th, 2005



"Boris" <spamno@hello.com> wrote in message
news:g5vZe.190$Aw.3400@typhoon.sonic.net...
Hi Boris,

The system events only have warnings:

DHCP warnings, sometime occur;
USER32 warnings, saying that the system fail to power off:
"The attempt to power off xxxxx failed"
(I guess this was caused by my program which prevents it from shutdown :=)

The above two warnings do not neccssarily occur together.




Posted by Boris on September 26th, 2005



"kiki" <lunaliu3@yahoo.com> wrote in message
news:dh6tg3$mgd$1@news.Stanford.EDU...
warnings seem to indicate that.
Do you use a WI-FI adapter? If so, try disabling it (via Control
Panel/Performance and Maintenance/System/Hardware/Device Manager) and see if
intermittent shut-downs still happen.
Basically, the approach here: try to find hardware/software configuration
that works fine (buy disabling or (physically)removing hardware). Once you
found such config, start putting devices back one at a time. That way it's
easier to identify the culprit device, I know, you suspect it's software
(Windows) rather than hardware problem. But every hardware device uses some
software (device driver), that could also be a culprit. Good starting point:
try booting into Safe Mode and see if problems still occur.

-Boris




Posted by kiki on September 26th, 2005


Hi all,

Here is the latest update about my program. I really need your desperately.

I have used the window message WM_QUERYENDSESSION, and make my
application returns Zeros to stop ending the session.

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

It stops shutdown successfully. I was very happy, until I found its
ordering:

I found out that all processes/applications which were loaded into memory
later than my "ShutDownPrevention" process, will respond to the above QUERY
message later than my program, so these applications are saved from the
shutdown.

But all those services/processes before my program was loaded, they will
respond to the Query message earlier than my program, so when my program
stopped the shutdown, these processes have already been shutdown already.
For example, the screen zooming utility, the Fn-keys of my laptop, screen
rotation utilities, all these things are gone. Because they install services
when startup and they stay in the notification area of the system tray. I
guess they have higher priority than my "ShutDownPrevention" program...

Anybody has thoughts on how to move my program above them?

One solution might be to load my program as service and make it load into
system as early as possible. How can I do that?

Thanks a lot!



Posted by Kellie Fitton on September 26th, 2005


Hi,

I don't quite understand what you are saying about the other programs
running on your system, however, you can try to set the priority of
your application's thread by calling the API SetThreadPriority().

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

Kellie.

Posted by kiki on September 26th, 2005





"Kellie Fitton" <KELLIEFITTON@YAHOO.COM> wrote in message
news:1127712492.517971.43830@f14g2000cwb.googlegro ups.com...
Hi Kellie,

I want to make sure before I get deep into it and do a lot debugging...

Here are the problems: I set my program to load on startup.

But it is defintely loaded into system later than those system processes,
Toshiba utilities processes(for example ,the process that handles the Fn
hotkeys on laptop, etc.)... these processes has been loaded into system
earlier than my program, even when I put it into startup menu.

I think that's because my program is not a service process.

Even if I make my program a service process, still there will be some
processes loaded before my program.

I did my experiment, all applications loaded into system later than my
program has got successfully stopped from shutting down by my program. But
those processes loaded into system earlier than my program was already
shutdown when my program had a chance to stop the whole crazy thing.

So now, is the SetPriority function still a good solution for my problem?

Thanks a lot!



Posted by Kellie Fitton on September 26th, 2005


Hi,

Try to create a hook into the windows message WM_QUERRYENDSESSION,
so you can have a bit more head start, otherWise, the system could
assumes an unresponsive process is dead, and takes actions against
it. Remember, every application gets the message WM_QUERYENDSESSION,
and in your reply, you can say "yes" or "no", but your answer is only
one vote, the first application to respond to this message stops the
polling by windows.

You need to use a system-wide hook, for example, WH_CALLWNDPROC to
monitor messages being sent, and WH_CALLWNDPROCRET to monitor the
messages handlers returning, and a hook procedure in a .DLL file.

Try to use the following API's:

SetWindowsHookEx()
CallNextHookEx()
UnhookWindowsHookEx()

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

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

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

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

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

Kellie.

Posted by Sten Westerback \(MVP SDK\) on October 4th, 2005



"kiki" <lunaliu3@yahoo.com> wrote in message
news:dh9618$acd$1@news.Stanford.EDU...
e/setthreadpriority.asp
If you want to keep it an application then it will start fairly randomly and
late.

If you make it a service then you do have a lot more control. You have the
option of setting the startup order (tag and startup group) or dependency
for your service so that it starts before some other service.

Setting high priority during startup may also have some very slight
influence on
startup order as long as the target is the other applications before they
start
doing something. It may also help to "reorder" processes that are started
at "exactly the same time".

However, if all applications respond properly to WM_QUERYENDSESSION
within the system timeout then your "negative" response will cause no
processes
to end regardless of the startup order.

- Sten




Posted by Uv on October 12th, 2005


Hi

You're doing right by handline queryendsession. But to prevent other
apps from getting that message and quitting, use
SetProcessShutdownParameters() to get your process to be the first one
to be sent shutdown notifications.

Check out its documentation in MSDN out here:
http://msdn.microsoft.com/library/de...parameters.asp

HTH
Uv