Batch script run with schedule in windows - windows

I have a doStuff.bat script with this command :
"%HOME%\bin\groovy.bat" "%HOME%\bin\DoSth.groovy"
What can i do to get that command run every 5 minute without using Window Task Schedule?

The timeout command in modern windows will pause for 5 minutes/300 seconds.
#echo off
set "home=c:\home folder"
:loop
call "%HOME%\bin\groovy.bat" "%HOME%\bin\DoSth.groovy"
timeout 300
goto :loop

Related

How to schedule a batch script for every 30 minutes?

I want to know the batch script to be included in my present batch script to schedule it for every 30 minutes.
myscript.bat
#echo off
java -jar myscript.jar
If you are asking how to loop the script with a 30 minute timeout between execution of java, then:
#echo off
:start
java -jar myscript.jar
timeout /t 1800 /nobreak >nul 2>&1
goto :start
if you wanted to actually schedule it to run every 30 minutes, then use your task scheduler.

Need a batch file to start, delay a close, and restart another batch file.

I have searched and searched and this is the closest code I have found:
#echo off
:loop
C:\CryptoCurrency\nexus_cpuminer\start.bat
timeout /t 30 >null
taskkill /f /im nexus_cpuminer.exe >nul
goto loop
A few things: notice the start.bat. The .exe I need to launch has to start via the .bat file because the .bat file contains information the .exe needs.
Secondly, the .exe launches a CMD prompt window which shows me what's going on.
(keep this in mind because this is not your normal .exe, I WANT that CMD prompt window to close when it's KILLED)
I am aware I have it set for 30 seconds. I'm just testing right now. I'd like to set it for 4 hours before the kill command is called. Also, I'd like to set a "delay" of 30 seconds before the whole process starts over. I am running Windows 7 x 64.
You must change the name of the second Batch file to other name (i.e. starter.bat) and execute it via the start internal command in order to execute it in parallel:
#echo off
:loop
start "" cmd /C "C:\CryptoCurrency\nexus_cpuminer\starter.bat"
timeout /t 30 >null
taskkill /f /im nexus_cpuminer.exe >nul
goto loop
The last line in starter.bat file must be the execution of nexus_cpuminer.exe, so when it is killed via taskkill, the .bat file ends immediately.
Another simpler approach is to directly execute nexus_cpuminer.exe in this Batch file, via start "" cmd /C nexus_cpuminer.exe command, so this process be opened in its own cmd.exe window.
If you CALL start.bat, it will return to your 'calling' script.
If you give start.bat a TITLE, you can /FIlter your TASKKILL command to EQ that WINDOWTITLE

Windows: Need to force close a process every few minutes so that batch script can start it up again

I have a batch script that starts up a process whenever it detects that the process was closed. I need to force close the process somehow on a set interval loop to see if the batch script is working as it should. What would be the best way to do this? I tried using another batch script to close the process, but didn't get the result as expected since both batch scripts open in the same command window.
In a second script, loop with goto and use a ping for pause.
:loop
:: 301 = 5 minutes. The first ping response is instant.
ping -n 301 0.0.0.0 >NUL
taskkill /im "program.exe" /f
goto loop

Run batch/bash command repeatedly over a period with pauses in between

To be clear, I'm seeking an implementation of this in both windows command line (batch file) and in a bash shell. Here is what I want to do:
Run a task/command
Kill the task after running for 1 hour
Wait 2 hours, then repeat(loop)
Preferably with a pure implementation in batch/bash. I've looked a bit around, but have not been able to find a solution to this, plus I'm a beginner, so any hints in the right direction will be appreciated!
For a batch version
#echo off
setlocal enableextensions disabledelayedexpansion
for /l %%a in () do (
start "" myTask.exe
timeout /t 3600
taskkill /im myTask.exe /f
timeout /t 7200
)
Create an infinite loop repeating the indicated sequence start / wait / kill / waitMore
I think You can use something like this in bash :
while true
do
sleep 3600
kill task
done
Have you tried using cron? You can create a script that runs the command, waits 1 hour and exits, which you can set it to run every 3 hours.

How to run a .vbs from a .bat

Created an extensive batch script program to handle some automated file management and printing and I need to call a vbs file for its sendkeys operation. Is there a way to accomplish this without freezing the program?
I've tried START /WAIT my.vbs and the script freezes when it enters the .vbs
Anyone have other methods or switches you would recommend?
I would like it to run silently if at all possible, and i need the /WAIT switch because I need the sendkeys operation to complete prior to the next step in the batch file.
Instead of using START /WAIT my.vbs you could try using cscript //NoLogo //B my.vbs. You can also pass other options to cscript that way.
Just Call The vbs file correct path
The BAT file Edit it...!!!
wscript "file-path"
Example:
wscript "D:\KmaniZoro\PGM\N++\VBS\inputbox.vbs"
timeout 5
timeout /?
TIMEOUT [/T] timeout [/NOBREAK]
Description:
This utility accepts a timeout parameter to wait for the specified
time period (in seconds) or until any key is pressed. It also
accepts a parameter to ignore the key press.
Parameter List:
/T timeout Specifies the number of seconds to wait.
Valid range is -1 to 99999 seconds.
/NOBREAK Ignore key presses and wait specified time.
/? Displays this help message.
NOTE: A timeout value of -1 means to wait indefinitely for a key press.
Examples:
TIMEOUT /?
TIMEOUT /T 10
TIMEOUT /T 300 /NOBREAK
TIMEOUT /T -1
Create the .vbs file Then open the Batch file and enter START "" "FILE PATH"
EG: Start "" "C:\Users\%Username%\Desktop\Spiritual Aid\Program\2.vbs"
IT WORKED PERFERCTLY IN MY COMPUTER.

Resources