Can I programmatically stop the shutdown process? Can I make my computer never shut down?

R

Roman Green

I would also advise to prove that the shutdown is not caused by some app or
service.
You may put a kind of system-wide breakpoint at user32!ExitWindowsEx for
this.
 
N

networm

TC said:
networm wrote:

(snip)



Try control panel Power Management & see what it says about the hard
disk's powerdown time?

HTH,
TC


I have set it to be "when AC is connected, never powerdown harddisk"....

What's wrong?

yeah, I read online there are some discussions about the trickness of this
setting,
 
N

networm

Gary Chanson said:
Then it's likely to be a hardware problem and curing it by blocking the
shutdown is the wrong approach. If it's shutting down because it's
overheating, you may have a failed fan. If abrupt motion causes it, you
may have a bad connection somewhere in the unit.

Whatever is causing this problem is not normal and fixing it via a
special program is just hiding the problem instead of solving it.


Please see my other posts: I have partially succeeded in making my laptop
never shutdown.

Everything worked properly, there was no fan-malfunctioning, harddisk
burning... no...
 
N

networm

Dear Roman,

I beleive your suggestion is a great one. But your idea is beyong my levels.
I am basically not a very good programmer.

I wish I could know which app/service is the bad guy, but I have worked hard
on it for 30 days... I spent hundreds of hours fighting on it since I had
this M4 laptop.

There is no event in the system events: there was one DHCP warning, but
that's only warning. It might be coupled with M4 wirelss fail to get scan
list when resuming from standby. But that's a wireless problem, even I stop
shutdown, this wireless problem still happens; even sometimes it does not
shutdown, this wireless problem still happens. Even if I turn off Wi-Fi
using hardware button(there is an external button on the laptop), the
mysterious shutdown still occurs...

And how to set a systemwide breakout?

I would apprecite greatly if you could elaborate on your suggestions... It
is really beyond my level.
 
N

networm

Thank you so much!

Can this one make my program the 1st to be Queried on overall Windows XP Pro
system, ahead of all those services?

There are two kinds of services I need to take care of: ones from MS, and
the others from Toshiba(since this is Toshiba laptop).

Anyway, I want my program to jump ahead at least in front of Toshiba
processes and services; I am not sure if I can completely jump ahead in
front of all MS processes... I am not sure. I do hope.

Thus, when it gets shutdown, my program will stop the shutdown from the very
beginning: allowing no service/program/appliations to be closed...
 
N

networm

Please see below:

Roman Green said:
Try SetProcessShutdownParameters.

Quite confusing:

What's the highest I can go?

Can I set dwLevel to be 4FF? or higher?

I am going to use: SHUTDOWN_NORETRY for dwFlag, since I want my program to
respond to the "WM_QueryEndSession" in no time.



Parameters
dwLevel
[in] Shutdown priority for a process relative to other processes in the
system. The system shuts down processes from high dwLevel values to low. The
highest and lowest shutdown priorities are reserved for system components.
This parameter must be in the following range of values. Value Meaning
000-0FF System reserved last shutdown range.
100-1FF Application reserved last shutdown range.
200-2FF Application reserved "in between" shutdown range.
300-3FF Application reserved first shutdown range.
400-4FF System reserved first shutdown range.


All processes start at shutdown level 0x280.


dwFlags
[in] Flags. This parameter can be the following value. Value Meaning
SHUTDOWN_NORETRY
0x00000001 The system terminates the process without displaying a
retry dialog box for the user.
 
K

Kellie Fitton

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/default.asp?url=/library/en-us/sysinfo/base/wm_queryendsession.asp

http://msdn.microsoft.com/library/d...kreference/hookfunctions/setwindowshookex.asp

http://msdn.microsoft.com/library/d...ookreference/hookfunctions/callnexthookex.asp

http://msdn.microsoft.com/library/d...ference/hookfunctions/unhookwindowshookex.asp

http://msdn.microsoft.com/library/d...suserinterface/windowing/hooks/abouthooks.asp

Kellie.
 
C

Chris Doré

networm said:
Everything worked properly, there was no fan-malfunctioning, harddisk
burning... no...

If something isn't overheating, that doesn't mean that something else
doesn't think it is. Perhaps the defect is in the detection.

I believe some mobile machines have methods to try and detect falls and/or
rough conditions (actually, IIRC someone posted some questions here on how
to handle it in Windows, not sure if they ever solved their tight time limit
problem). Perhaps something like this is malfunctioning and thinking your
"harsh" lid open/close is bad enough to warrant a shutdown.


Regards, Chris
 
N

networm

If something isn't overheating, that doesn't mean that something else
doesn't think it is. Perhaps the defect is in the detection.

I believe some mobile machines have methods to try and detect falls and/or
rough conditions (actually, IIRC someone posted some questions here on how
to handle it in Windows, not sure if they ever solved their tight time
limit problem). Perhaps something like this is malfunctioning and
thinking your "harsh" lid open/close is bad enough to warrant a shutdown.


Regards, Chris

Exactly... or when the AC is still connected while the battery is full, it
almost always shutdown.

That's why I am now desperately trying to find a workaround... I partially
succeeded... as you have seen....
 
N

networm

Kellie, that's really beyong me...
What a pity... whenever I see "system" and "hooker", etc. I got
frustrated...

Any existing code examples?

Thanks a lot! you are a nice guy!
 
G

Gary Chanson

networm said:
Exactly... or when the AC is still connected while the battery is full, it
almost always shutdown.

That's why I am now desperately trying to find a workaround... I partially
succeeded... as you have seen....

If you can't identify and fix the problem, you should return the unit for
repair or replacement. Disabling shutdown in software in not the proper
approach. What you're doing is equivalent to putting black tape over the low
oil pressure light in your car because it's flashing at you, instead of
finding out what is causing the indication.
 
N

networm

You think the service guy can solve the problem?
No way!

I have talked with them over the phone for many hours,

they are far less expert than the great talents here on these forums...

All they can suggest is to do a recovery by reinstalling: wash away
everthing.

If I return to them: they still cannot solve it after many months: there are
so many complaints about these problems: I believe they are not hardware
problmes soly but XP Tablet PC problems.

Even they give me full refund, I still need to use one Tablet PC urgently.

I am currently having success in preventing shutting down. I followed
Roman's suggestion: I set my program's dwLevel to be 0x4ff... guess what, it
does not shutdown any process at all. So far so good. I also found solution
to that mysterious wireless failure after resume problem.

I am going to continue trial and error on it and keep you post!

thanks a lot guys!
 
N

networm

Roman - I set dwLevel to 0x4ff, it succeeded for today. My Tablet PC becomes
unfailable! :=) It never shuts down! Great advice! Thank you so much!

I am going to continue experimenting on it and see if problem still persists
and keep you post tomorrow!
 
R

Roman Green

Hi, networm
I still think you should investigate what is the origin of the problem.
If you can use a kernel debugger (WinDbg, SoftICE etc.) I think the simplest
way would be to set a breakpoint on nt!_PrepareForLogoff.
 
T

TC

If it keeps shutting down when it /should not/ shut down, you either:

(a) take it back whgere you got it & tell them to fix it or provide a
new one, or

(b) take it to a competenet repair technician & get him/her to fix it
for you.

Or alternatively, you could try the following option, which is 100%
guaratneed to (1) waste tons of your time, and (2) not fix it anyway:

(c) frig around trying to get a software solution to what is probably a
hardware problem!

Just my 2c ...

TC
 
T

TC

Um, read what he's written so far in this thread, then take bets on
whether he can use a kernel debugger!

No offence - I can't use a kernel debugger myself - but, I think the
advice should be tailored to the situation. This guy is ignoring the
fire, by throwin a blanket over it. IMO he is going nowhere quickly,
until he takes the friggin' thing back, to be repaired!

TC
 
S

Scherbina Vladimir

Let's take a look at the situation from another view.

When your laptop goes to standby system sends WM_POWERBROADCAST message with
wParam PBT_APMSUSPEND to all applications. When application recieves this
message it shoud complete processing and be ready for "freezing".

Then you open your laptop, system is sending WM_POWERBROADCAST with wParam
PBT_APMRESUMESUSPEND to applications and they should prepare to continue
working.

The shutdown problem may occure when some service recieves WM_POWERBROADCAST
message with wParam PBT_APMRESUMESUSPEND and something goes wrong in it's
handler and this causes service to initiate shoutdown sequance.

How to detect what's exactly wrong ? At first try to simulate standby.Write
an application that sends WM_POWERBROADCAST to all applications
(SendMessageA supports broadcast option).
After sending wait 20 seconds and then "resume" them by sending the same
message with PBT_APMRESUMESUSPEND flag.

If your computer will be shutdowning in this case then the problem is in
handlers of WM_POWERBROADCAST.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top