# How to prevent an application from shutting down the PC?

**URL:** <https://boards.straightdope.com/t/how-to-prevent-an-application-from-shutting-down-the-pc/376953>\
**Category:** Factual Questions\
**Created:** [October 18, 2006, 4:20pm UTC](https://boards.straightdope.com/t/how-to-prevent-an-application-from-shutting-down-the-pc/376953 "2006-10-18T16:20:25Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Puzzler](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@Puzzler](https://boards.straightdope.com/u/Puzzler)\
**Post date:** [October 18, 2006, 4:20pm UTC](https://boards.straightdope.com/t/how-to-prevent-an-application-from-shutting-down-the-pc/376953/1 "2006-10-18T16:20:25Z")

</div>

I have installed a certain system on my PC. The systems software is usually installed on dedicated computers. Hence, it is started on boot, takes control of the PC, and shut down the PC on exit.

I intend to use it on a general-purpose PC (running XP-Pro). It was rather easy to prevent the system from initiating on startup (by taking it off the start menu). I can also access my PC using the keyboard start button.

My problem is that the application still shuts down the PC upon exit.  
Is there a way to stop it (say, another app that stops shut downs and asks permission)?

---

<div class="post-metadata">

**Author:** ![drachillix](https://avatars.discourse-cdn.com/v4/letter/d/48db29/32.png) [@drachillix](https://boards.straightdope.com/u/drachillix)\
**Post date:** [October 18, 2006, 4:31pm UTC](https://boards.straightdope.com/t/how-to-prevent-an-application-from-shutting-down-the-pc/376953/2 "2006-10-18T16:31:37Z")

</div>

[QUOTE=Puzzler]  
I have installed a certain system on my PC. The systems software is usually installed on dedicated computers. Hence, it is started on boot, takes control of the PC, and shut down the PC on exit.  
[/QUOTE]

#1 we would probably need to know the app?

#2 Perhaps tech support from the maker of the software could be helpful.

---

<div class="post-metadata">

**Author:** ![Puzzler](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@Puzzler](https://boards.straightdope.com/u/Puzzler)\
**Post date:** [October 18, 2006, 4:52pm UTC](https://boards.straightdope.com/t/how-to-prevent-an-application-from-shutting-down-the-pc/376953/3 "2006-10-18T16:52:55Z")

</div>

[QUOTE=drachillix]  
#1 we would probably need to know the app?

[/quote]

The app itself does not support non-shutdown. I’m looking for a way to bypass the problem.

> [@](#):
>
> #2 Perhaps tech support from the maker of the software could be helpful.

I’ve tried. As I said, they aim their application for closed systems (HW+SW, they sell both). While not illegal to work as I do, they do not support it.

---

<div class="post-metadata">

**Author:** ![gotpasswords](https://avatars.discourse-cdn.com/v4/letter/g/c57346/32.png) [@gotpasswords](https://boards.straightdope.com/u/gotpasswords)\
**Post date:** [October 18, 2006, 4:53pm UTC](https://boards.straightdope.com/t/how-to-prevent-an-application-from-shutting-down-the-pc/376953/4 "2006-10-18T16:53:06Z")

</div>

Whatever this is, it’s sounding more like an operating system than an application. Aside from the typical “Your computer must be restarted for this update/installation to take effect” restart, I’m not aware of anything that can get around XP’s grip on the hardware to force a restart.

---

<div class="post-metadata">

**Author:** ![gotpasswords](https://avatars.discourse-cdn.com/v4/letter/g/c57346/32.png) [@gotpasswords](https://boards.straightdope.com/u/gotpasswords)\
**Post date:** [October 18, 2006, 4:57pm UTC](https://boards.straightdope.com/t/how-to-prevent-an-application-from-shutting-down-the-pc/376953/5 "2006-10-18T16:57:23Z")

</div>

[QUOTE=Puzzler]  
The app itself does not support non-shutdown. I’m looking for a way to bypass the problem.  
[/QUOTE]

Can you run it in a virtual machine? That way, only the VM should die when the app shuts down and tries to take Windows with it.

Microsoft offers [Microsoft Virtual PC](http://www.microsoft.com/windows/virtualpc/evaluation/faq.mspx) for free, or you could try something like [VMware](http://www.vmware.com/)

---

<div class="post-metadata">

**Author:** ![Number](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/number/32/242_2.png) [@Number](https://boards.straightdope.com/u/Number)\
**Post date:** [October 18, 2006, 10:52pm UTC](https://boards.straightdope.com/t/how-to-prevent-an-application-from-shutting-down-the-pc/376953/6 "2006-10-18T22:52:20Z")

</div>

Running it in a VM is a good idea.

There is one other way that might work. This assumes that your normal account is a member of the local Administrators group.

1. Run **gpedit.msc**.

2. Expand **Computer Configuration\Windows Settings\Security Settings\Local Policies\User Rights Assignment** and remove the the **Shut down the system** right from the Users group (do not remove it from Administrators).

3. Create a new local user.

4. Create a .cmd file to launch the program under this new user’s account using the RUNAS command, e.g. **runas /env /user:newuser C:\program.exe**.

This should prevent the program from shutting down the machine.

---

<div class="post-metadata">

**Author:** ![Puzzler](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@Puzzler](https://boards.straightdope.com/u/Puzzler)\
**Post date:** [October 18, 2006, 11:56pm UTC](https://boards.straightdope.com/t/how-to-prevent-an-application-from-shutting-down-the-pc/376953/7 "2006-10-18T23:56:24Z")

</div>

**gotpasswords** , thank you. I will try that if I won’t find a more direct way (even though I must admit it sounds quite elegant, I have no experience with VMs).

**Number** ,  
I have followed steps 1-3. Would you mind expanding a bit re step 4? Do I need to switch to the new user account? How do I create the cmd file?  
Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Number](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/number/32/242_2.png) [@Number](https://boards.straightdope.com/u/Number)\
**Post date:** [October 19, 2006, 12:27am UTC](https://boards.straightdope.com/t/how-to-prevent-an-application-from-shutting-down-the-pc/376953/8 "2006-10-19T00:27:09Z")

</div>

[QUOTE=Puzzler]  
**gotpasswords** , thank you. I will try that if I won’t find a more direct way (even though I must admit it sounds quite elegant, I have no experience with VMs).

**Number** ,  
I have followed steps 1-3. Would you mind expanding a bit re step 4? Do I need to switch to the new user account? How do I create the cmd file?  
Thanks in advance!  
[/QUOTE]  
No, stay logged on as yourself. Create a new text file on your desktop. Open it and enter **runas /env /user:newuser C:\program.exe** , where **newuser** is the name of the user you created in Step 3 and **C:\program.exe** is the full path of the program. Save it, then rename it with a .cmd extension instead of .txt.

Double-clicking this file will run the command. It should prompt you for the new user’s password and then launch the program using their credentials.

---

<div class="post-metadata">

**Author:** ![Puzzler](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@Puzzler](https://boards.straightdope.com/u/Puzzler)\
**Post date:** [October 19, 2006, 12:40am UTC](https://boards.straightdope.com/t/how-to-prevent-an-application-from-shutting-down-the-pc/376953/9 "2006-10-19T00:40:18Z")

</div>

[QUOTE=Number]  
No, stay logged on as yourself. Create a new text file on your desktop. Open it and enter **runas /env /user:newuser C:\program.exe** , where **newuser** is the name of the user you created in Step 3 and **C:\program.exe** is the full path of the program. Save it, then rename it with a .cmd extension instead of .txt.

Double-clicking this file will run the command. It should prompt you for the new user’s password and then launch the program using their credentials.  
[/QUOTE]

Hmmm…  
Did that. When I run it, it asks for a password (there isn’t one). I hit Enter, and the window closes without running the app.  
Do I need just the new user name, or some more info (e.g., computer name)?

---

<div class="post-metadata">

**Author:** ![Number](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/number/32/242_2.png) [@Number](https://boards.straightdope.com/u/Number)\
**Post date:** [October 19, 2006, 12:47am UTC](https://boards.straightdope.com/t/how-to-prevent-an-application-from-shutting-down-the-pc/376953/10 "2006-10-19T00:47:37Z")

</div>

Try running it from the command line and see if it comes up with any errors.

---

<div class="post-metadata">

**Author:** ![Puzzler](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@Puzzler](https://boards.straightdope.com/u/Puzzler)\
**Post date:** [October 19, 2006, 1:03am UTC](https://boards.straightdope.com/t/how-to-prevent-an-application-from-shutting-down-the-pc/376953/11 "2006-10-19T01:03:03Z")

</div>

I added a password (just to be on the safe side…)

Now, when I enter the password, it types:  
Attempting to start \<app\> as user “\<comp name\>&lt;username\>” …  
In .cmd: nothing  
In cmd windows: a window pops saying  
Initialize information error  
Please reinstall software  
BTW: I found an old discussion about this app in a different forum. It seems this is a known problem. The “usual” way around it is to kill the app via task manager. But I’d ather not - this apps keeps a database, and I’m affraid it may get curropted this way.

---

<div class="post-metadata">

**Author:** ![Fredescu](https://avatars.discourse-cdn.com/v4/letter/f/73ab20/32.png) [@Fredescu](https://boards.straightdope.com/u/Fredescu)\
**Post date:** [October 19, 2006, 1:23am UTC](https://boards.straightdope.com/t/how-to-prevent-an-application-from-shutting-down-the-pc/376953/12 "2006-10-19T01:23:21Z")

</div>

> [@Puzzler](#):
>
> (say, another app that stops shut downs and asks permission)

An unsaved notepad file usually stops shutdowns and just sits there waiting for your input about saving the file. If you hit cancel, it stops the shutdown in its tracks. Very inelegant, but I often have multiple notepads open and it has saved me a few times when I’ve forgotten to untick “Reboot now”

---

<div class="post-metadata">

**Author:** ![Mangetout](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/mangetout/32/19_2.png) [@Mangetout](https://boards.straightdope.com/u/Mangetout)\
**Post date:** [October 19, 2006, 8:49am UTC](https://boards.straightdope.com/t/how-to-prevent-an-application-from-shutting-down-the-pc/376953/13 "2006-10-19T08:49:36Z")

</div>

[QUOTE=Puzzler]  
I added a password (just to be on the safe side…)

Now, when I enter the password, it types:  
Attempting to start \<app\> as user “\<comp name\>&lt;username\>” …  
In .cmd: nothing  
In cmd windows: a window pops saying  
Initialize information error  
Please reinstall software  
[/QUOTE]

I would say that is an indication that the software you’re running requires (or at least _demands_) to be run with Admin privileges, perhaps only because the programmer wanted it that way, but perhaps for the very reason that it expects to be shutting down the machine when it is terminated.

---

<div class="post-metadata">

**Author:** ![Mangetout](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/mangetout/32/19_2.png) [@Mangetout](https://boards.straightdope.com/u/Mangetout)\
**Post date:** [October 19, 2006, 8:50am UTC](https://boards.straightdope.com/t/how-to-prevent-an-application-from-shutting-down-the-pc/376953/14 "2006-10-19T08:50:40Z")

</div>

BTW… isn’t there just another app you can use instead?

---

<div class="post-metadata">

**Author:** ![FRDE](https://avatars.discourse-cdn.com/v4/letter/f/e68b1a/32.png) [@FRDE](https://boards.straightdope.com/u/FRDE)\
**Post date:** [October 19, 2006, 9:41am UTC](https://boards.straightdope.com/t/how-to-prevent-an-application-from-shutting-down-the-pc/376953/15 "2006-10-19T09:41:25Z")

</div>

Using FileMon from [www.sysinternals.com](http://www.sysinternals.com) you should be able to determine whether the offending App closes its data files (it probably does, only a stupid programmer keeps files unflushed unnecessarily).

If that is the case, then Task Manager shutdown should be safe.

Apps know (roughly) where the command to shut down comes from, so my guess is that it tries to power off the machine **unless** it thinks the machine is about to be powered off.

On an NT based machine you have to jump through some hoops changing privileges to use ExitWindowsEx to power off.

AdjustTokenPrivileges is at the core of that little rats nest, but I reckon that one could flip the system out of Admin mode.

Just looking into the problem makes me feel slightly queasy.

---

<div class="post-metadata">

**Author:** ![Smitty](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@Smitty](https://boards.straightdope.com/u/Smitty)\
**Post date:** [October 19, 2006, 2:07pm UTC](https://boards.straightdope.com/t/how-to-prevent-an-application-from-shutting-down-the-pc/376953/16 "2006-10-19T14:07:57Z")

</div>

How much time do you have before the machine shuts down? You can go to Start -\> Run and type in **shutdown /a** which will prevent a system shut down, if you have time enough to do it.

---

<div class="post-metadata">

**Author:** ![Puzzler](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@Puzzler](https://boards.straightdope.com/u/Puzzler)\
**Post date:** [October 20, 2006, 10:32am UTC](https://boards.straightdope.com/t/how-to-prevent-an-application-from-shutting-down-the-pc/376953/17 "2006-10-20T10:32:41Z")

</div>

Thanks, everyone, for the suggestions.

[QUOTE=Fredescu]  
An unsaved notepad file usually stops shutdowns and just sits there waiting for your input about saving the file. If you hit cancel, it stops the shutdown in its tracks. Very inelegant, but I often have multiple notepads open and it has saved me a few times when I’ve forgotten to untick “Reboot now”  
[/QUOTE]

It did indeed stop the shutdown, but not before the app managed (I think) to make some damage. For example, the taskbar icons are gone. And there is an app window that won’t close.

[QUOTE=Mangetout]  
BTW… isn’t there just another app you can use instead?  
[/QUOTE]

Probably… The thing is this app came with the HW I bought, and any replacement app must work with it. And in any case, it will probably cost more than I’m willing to spend.

[QUOTE=FRDE]  
Using FileMon from [www.sysinternals.com](http://www.sysinternals.com) you should be able to determine whether the offending App closes its data files (it probably does, only a stupid programmer keeps files unflushed unnecessarily).

If that is the case, then Task Manager shutdown should be safe.

Apps know (roughly) where the command to shut down comes from, so my guess is that it tries to power off the machine **unless** it thinks the machine is about to be powered off.

[/QUOTE]

I’ll try that. The thing is, the app in question is a surveillance system. It continuously collects camera data and stores it into the database. So I assume at any given minute the DB may be open.

[QUOTE=Smitty]  
How much time do you have before the machine shuts down? You can go to Start -\> Run and type in **shutdown /a** which will prevent a system shut down, if you have time enough to do it.  
[/QUOTE]

I do have a couple of seconds. But guess what: the app won’t let me access the “run” command. So, only after the app exists, and shutdown is well under way am I able to try that…  
I’m beginning to think it’s a lost battle.  
I will attempt to try the filemon re DB state. I will also try to re-install the app under the user account (although it takes a l-o-n-g time - it has to format a dedicated partition for it!).  
I will also look into the VM idea.

Will report results.  
Thanks again.

---

<div class="post-metadata">

**Author:** ![Puzzler](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@Puzzler](https://boards.straightdope.com/u/Puzzler)\
**Post date:** [October 23, 2006, 12:38pm UTC](https://boards.straightdope.com/t/how-to-prevent-an-application-from-shutting-down-the-pc/376953/18 "2006-10-23T12:38:23Z")

</div>

OK, promised an update.  
filemon says app writes to disk all the time. So reboot may be not safe.  
installing VM stoped my internet.  
Later, my sys disk crashed.  
So this app is not really my top priority now…

Puzzler
