I have read all that stuff about time saving and I wan't to create a shortcut to my IM app that won't run on odd days. It is possible in Windows Vista batch?
You can try using the Windows Task Scheduler
I'm rusty with batch files, but I think what you want to do in pseudocode is:
if %DAY% mod 2 = 0 then run
(%DAY% should return the day of the month, but remember this won't run on the 31st or the 1st, so sometimes you will be stuck without your im application for two consecutive days)
Related
I need a solution on windows 7/10 to start a program at desirable time and close it at desirable time everyday automatically.
I'm running a program 24/7 and i need it to close at 00:00am and open it again at 00:01am
It's not very convenient to do it manually so i'm looking for solution. Maybe a .bat file or something i don't know.
I have no experience in coding whatsoever so i'm asking you guys for help.
You can use Windows Task Scheduler and define two jobs for start and stop your program at specific time everyday.
I am able to get PC last reboot time using VBS (Check Time of Last Boot).
So, Is there any way to get last last previous reboot time? (I mean second reboot time before last boot time)?
The easiest way would be to filter the event viewer, looking only for 6005/6006 events.
If it's only for one computer, you can create a log file by executing a script that write the current time in a task scheduler. Then, use another script to read the log file and get the time value.
If it's for a lot of computer, I don't know how you can do this.
I've written a simple autoupdater where I use a batch file with ftp commands to first download a "version" file, and compare the text to a local "version.txt" file - if the versions are different, I continue in the same batch script to download and install the update.
That part is fine, but when I create the task (using another batch file distributed in a setup.exe installer) since I need it to be run my hundreds of non-tech savvy users - I want to add a random time offset to the start time of the job, so that I don't have all terminals hitting my server for updates at exactly the same time.
SCHTASKS.EXE /CREATE /SC DAILY /ST 10:00 /TN "My Updater Task" /TR "c:\myupdater.bat"
I need this to be as compatible with XP as well as Vista+, but the majority user base would be XP. How can I put a different time like 10:05, 10:10, 10:00 etc. plus-minus 10 minutes to 10:00 so that I dont get hit by 200 clients simultaneously?
Also, is it possible to start the job without the command window showing? I've seen answers using vb script and cmdnow or some third party tool, which i'm not going to use for compatibility, virus scanner nuisance, and download requirements etc.
You could use %random% to generate your start time. There's a very useful forum discussion discussing how to do this in detail.
To run a batch file without the cmd window popping up try this (taken from here)
start /min myfile.bat
I found this post on how to edit %random% to return a more acceptable number. it might be of help to you How to use random in BATCH script?.
In other words, Windows starts up, and my application xyz.exe, is started at exactly 5 minutes after boot up. Is this possible to guarantee, within a margin of error of say 10-15 seconds?
It will probably be easier just to launch your app at windows startup and then sleep for 5 minutes before doing anything.
You can programtical modify a scedlued task after bootup or login to start your program.
I have a script running on windows box that downloads files from the net via http. I want it to download only from 1am - 8am (my ISP's off peak time). I am happy if already started download finishes after 8am but what is the best method to make sure that the script starts downloading after 1am? I want to run the script and go to sleep. I want to use ruby only.
Is sleep the best way how to do it?
There is a good article on this here: Scheduling tasks in Ruby / Rails
But as someone else mentioned, you should use the windows task scheduler to start your script. Unless you really want to start it manually at 1am and every time you reboot your windows box... See this other SO question on how to add a scheduled task using the AT DOS command: What is the Windows version of cron?