Page 1 of 1

Record Minutes Every 30 Minutes

Posted: 25 Jan 2011 03:15
by dockies
Hi,

I am a newbie when it comes to batch script, im trying to google everything that i need it's just so confusing for me and really dont have any idea how the batch works :(

Well if anyone here is kind enough to help me... this is my problem:

I need to record the minutes every 30 mins. given that the pc is turned on :D

Example:
i have a text file let say "minutes.txt"

Every 30 Minutes the script will record something like this...

>> 30 Minutes

After 30 Minutes

>> 60 Minutes

It should be in the same file. it doesn't matter if it overwrites the file or just write a new line or record inside the file.
And is it possible for a batch script to run without opening anything like DOS prompt? it will run in the background and no one
will see any difference in their screen.

Please i really need help for this :cry:

Thanks in advance.... :mrgreen:

Re: Record Minutes Every 30 Minutes

Posted: 25 Jan 2011 08:18
by ChickenSoup
Do you want the batch file to count down to the next 30 minute interval, or are you using something like the windows Task Scheduler to launch the batch file every 30 minutes?
Also, the only way to do it completely hidden is with vbScript that calls the batch (or do the whole thing in vbs).

Re: Record Minutes Every 30 Minutes

Posted: 25 Jan 2011 22:51
by dockies
Actually either way... as of now i am using task scheduler to run the script every 30 mins.

Yes i googled it already and this is what i have so far.

runme.bat

Code: Select all

@ECHO OFF
CLS
wscript.exe "invis.vbs" "minutes.bat"
CLS


invis.vbs

Code: Select all

CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False


minutes.bat

Code: Select all

echo 1 >> minutes.txt


yes it is writing in the file every 30 minutes the problem is the command promt screen still shows. :(

Thank you for your reply... hope to solve this soon :o

Re: Record Minutes Every 30 Minutes

Posted: 26 Jan 2011 08:27
by ChickenSoup
You are still seeing the command window because you are using a batch file to launch another batch file hidden.

Try RunMeHidden.vbs in your scheduled task:

Code: Select all

CreateObject("Wscript.Shell").Run "C:\Path\To\File\minutes.bat", 0, False

Re: Record Minutes Every 30 Minutes

Posted: 26 Jan 2011 08:36
by ChickenSoup
And for the minutes file to look how you originally posted.
Minutes.bat

Code: Select all

for /f "tokens=1" %%a in (minutes.txt) do set minutes=%%a
set /a minutes=%minutes%+30
echo.%minutes% minutes>>minutes.txt