
-----------------------------------
TokenHerbz
Mon Sep 11, 2006 1:33 am

Controlling programs with time?
-----------------------------------
How would i go about makeing a program that will do the following tasks.

-Read the current time on the computer.
-Boot programs up at a specific time.
-Close programs at a specific time.

-----------------------------------
Cervantes
Mon Sep 11, 2006 6:31 am


-----------------------------------
Look up the Time module. You can use things like Time.Date or Time.DateSec.

You can run programs with Sys.Exec.

You cannot close running programs. That's too advanced.

-----------------------------------
NikG
Mon Sep 11, 2006 9:25 am


-----------------------------------
The first two are simple just as Cervantes said.

If instead of closing a certain program, you want to turn off your computer (thereby closing all programs), I remember seeing some code here to do just that using Sys.Exec.

-----------------------------------
Wolf_Destiny
Mon Sep 11, 2006 2:12 pm

Tada
-----------------------------------
Here ya go:

To simply shutdown:
if Sys.Exec ("shutdown -s") then
%Successful!
end if
Timer: (Where 60 is a changable amount of seconds before shutdown)
if Sys.Exec ("shutdown -s -t 60") then
%Successful!
end if
Timer and Comment
if Sys.Exec ("shutdown -s -t 60 -c "YOUR COMMENT HERE"") then
%Successful!
end if


To simply restart:
if Sys.Exec ("shutdown -r") then
%Successful!
end if
Timer: (Where 60 is a changable amount of seconds before reboot)
if Sys.Exec ("shutdown -r -t 60") then
%Successful!
end if
Timer and Comment
if Sys.Exec ("shutdown -r -t 60 -c "YOUR COMMENT HERE"") then
%Successful!
end if

-->And while experimenting |    shutdown -a    | in the command prompt will cancel a shutdown command (If on timer)

Enjoy,
~Wolf_Destiny

-----------------------------------
Wolf_Destiny
Mon Sep 11, 2006 2:38 pm


-----------------------------------
Just Remembered this:

In WinXP there is a "taskkill" command for DOS. (I believe it's called "kill" for Win2000)

It allows you to terminate any process currently running ONE AT A TIME just like you want, right Tokenherbs? So how does it work?

First off, you need to know what's called the image name, that the program runs under. Example firefox's image name is "firefox.exe" it's simply, but neccessary. So to do this:
1. Open your program of choice (the one that Turing will close).
2. Start Menu -> Run -> Command taskkill -F -IM 
So to close firefox immediately:
taskkill -F -IM firefox.exe
7. Put that line into a Sys.Exec Structure.
if Sys.Exec ("taskkill -F -IM firefox.exe") then
put "This program just closed firefox, how d'ya like that?"
end if

A closer look:
-F tells the command prompt to force the program to close
-IM tells the command prompt that the image name is to follow
 tells the command prompt what the heck you want to close

Hope that helps!
~Wolf_Destiny

-----------------------------------
NikG
Tue Sep 12, 2006 4:50 pm


-----------------------------------
Wow, pretty impressive WolfDestiny.

Just to clarify two things for all future seekers of this kind of programs:

-This is being done using exisiting windows apps.  So Cervantes is still correct in saying that Turing itself cannot do this.

-WoldDestiny just demonstrated the various different switches that can be used with the taskkill and shutdown apps.  To find them on your own, all you have to do is open the command prompt, and type in the command followed by a "/?" (i.e. shutdown /?) to get the full list of switches available.
