Jump to content

Schedule A Script


 Share

Recommended Posts

It's been a while since I worked with NT4, but I believe that there should be file called "soon.exe" which resides in the System32 directory. I'm not sure if this file comes standard, or within a service pack/resource kit.

If the command exists in your environment, then the statement soon 1800 myscript.exe may be used to slate myscript.exe to be executed in 1,800 seconds (30 minutes) from the current time. Simply call the soon utility from your script to schedule execution again in another half hour.

If you don't have the soon utlitly, then you'll need to resort to the "at.exe" utility to schedule the tasks. The syntax for the at utility is a little different, but still easy to use. You won't be able to specify the task is to be executed in xx seconds from now, but you can specify the desired time: at 15:30 "myscript.exe"

Hope this helps! :whistle:

Link to comment
Share on other sites

I normally use squeduler, but you can do it in AutoIt very easy.

This example will back it up every 30 min. Change the filecopy to run your program if you wish.

I normally have things only backup durring business hours, but that is easy enough to add.

Just compile it after you are satisfied, and place in the startup. You can also get an Ini file going with filenames, etc, but this is simply a quick example to learn from.

Sqeduler is much better, due to permisions, login passwords, ect. You can always have it run this once a day at say 9:00am, and have it turn it off if running for over 8 hours, and bam you have it backing up from 9~5 every 30 min. :whistle:

Winclose("MyBackup"); make sure only one is running
sleep(1000)
AutoItWinSetTitle ("MyBackup")
AutoItSetOption("TrayIconHide", 0);1 = Hide Icon change to hide if you like.
$done=""
While 1
For $i=0 To 3; really only need 0 and 3 for once every 30 min
    If int(@MIN /10)=$i  and $i<>$done Then
  FileCopy ("c:\myfile.txt","C:\backup\myfile.txt",1); change this to suit you
  $done=$i ; once done, this will make sure it doesn't till the next time
    EndIf
Next
    sleep(1000); slight delay saves CPU
Wend

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...