Jump to content
Sign in to follow this  

check for a process - and if no process - then restart the computer

Recommended Posts

hello everyone,

Im trying to find a function that will let me check fore the precsence of a process AKA a running program. And if that process terminates/program is closed then computer restarts or logs off.

Its for a kiosk type computer that should only be running one program.

Thanks for ay ifo!

Share this post

Link to post
Share on other sites

If ProcessExists("notepad.exe") Then
    MsgBox(0, "Example", "Notepad is running.")
Shutdown(2) ;reboot

The shutdown code is a combination of the following values:

0 = Logoff

1 = Shutdown

2 = Reboot

4 = Force

8 = Power down

32= Suspend

64= Hibernate

Add the required values together. To shutdown and power down, for example, the code would be 9 (shutdown + power down = 1 + 8 = 9).

Standby or hibernate are ignored if other codes are set. They are also ignored under Win9x.

Edited by CWorks

Share this post

Link to post
Share on other sites

i got this to work - but in a very bad way. I need my script to watch continually for the process. So what i did (very stupidly) was create an infinite loop to run my check process script.

It works great - except it uses 100% of CPU.

How can i achieve this without infinite loops? (sorry im not very good!)

Share this post

Link to post
Share on other sites

Your script is trying it's best to go thru that loop as fast a possible, resulting in a very

high CPU-usage. The solution is to put a tiny sleep in your loop somewhere. 10 ms is

what I usually use.

Share this post

Link to post
Share on other sites

fantastic reply! Thanks alot that was it.

I now have another question - i want to hide the startbar for this kiosk computer, however what would be perfect is to kill the explorer.exe process.

Problem is when i kill the process with ProcessClose windows regenerates it and brings back the startbar and the like.

Anyone have same porbles,?


Share this post

Link to post
Share on other sites


you can set the sleep command to 500 ms I gues.

and check this .

Opt ("WinTitleMatchMode", 4)

Sleep (5000)

So long,


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...