Sign in to follow this  
Followers 0
prpldodge

Schedule A Script

8 posts in this topic

Does anyone have an idea how to create a script that will run say every half hour.

or even just once a day With out havening to do it manually

I have a script that backs up a file to another computer.

Thanks

Alan

Share this post


Link to post
Share on other sites



Windows task scheduler?

Share this post


Link to post
Share on other sites

It needs to run on windows nt 4.0 server

Share this post


Link to post
Share on other sites

What about doing a loop and add a sleep in it ?

While 1
Sleep(60000)
MsgBox(0, "Title", "I've been waiting for 1 minute!")
Wend

Share this post


Link to post
Share on other sites

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:

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Thanks Every one I will give it a try

Alan

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  
Followers 0