Jump to content

Recommended Posts

Posted

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!

Posted (edited)

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

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
Posted

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!)

Posted

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.

Posted

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,?

thanks

Posted

HI,

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

and check this .

Opt ("WinTitleMatchMode", 4)

Winsetstate("classname=Shell_TrayWnd","",@SW_HIDE)
Sleep (5000)
Winsetstate("classname=Shell_TrayWnd","",@SW_Show)

So long,

Mega

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

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
×
×
  • Create New...