Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: number of times started  (Read 18925 times)

0 Members and 1 Guest are viewing this topic.

Lemonilla



    Apprentice

  • "Too sweet"
  • Thanked: 70
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Re: number of times started
« Reply #45 on: November 19, 2014, 07:16:23 PM »
try this:
Code: [Select]
@echo off
setlocal EnableDelayedExpansion
set file1=FILE1.exe
set file2=FILE2.exe


if not exist log1.txt (
REM we are on our first run
echo 1 >log1.txt
%file1%
) else (
REM iteration > 1
set /p num=<log1.txt
if "!num!"=="5" (
REM run file2
if not exist log2.txt (
REM First time running file2
echo 1 >log2.txt
%file2%
) else (
set /p num2=<log2.txt
if !num2! LEQ 3 exit /b
set /a num2+=1
echo !num2! >log2.txt
%file2%
)
) else (
set /a num+=1
echo !num! >log.txt
%file1%
)
)
Quote from: patio
God Bless the DOS Helpers...
Quote
If it compiles, send the files.

Jaka

  • Guest
Re: number of times started
« Reply #46 on: November 20, 2014, 01:53:51 AM »
thank you for batch.
But something not working.
When I start batch it makes log1.txt and write 1 into it
when i start second time it makes log.txt and write 2 into it
and thats it, no matter how many times I start script after that it opens file1.exe and nothing happend with log1.txt and log.txt

Lemonilla



    Apprentice

  • "Too sweet"
  • Thanked: 70
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Re: number of times started
« Reply #47 on: November 20, 2014, 05:00:12 PM »
Walk your way through the code and follow the logic.  There is a minor fix that needs to be done that you can do yourself by examining the parts that work.
Quote from: patio
God Bless the DOS Helpers...
Quote
If it compiles, send the files.

Squashman



    Specialist
  • Thanked: 134
  • Experience: Experienced
  • OS: Other
Re: number of times started
« Reply #48 on: November 20, 2014, 07:28:56 PM »
Hint. How many log files are you suppose to have and what should they be named.

Jaka

  • Guest
Re: number of times started
« Reply #49 on: November 22, 2014, 04:30:19 AM »
OK I think I found a problem :D
It was the end of script I changed log.txt to log1.txt
but now it counts over 5, to 6 or 7 or 8, etc. And doesn't open file2.exe, still opens file1.exe.



Code: [Select]
)
) else (
set /a num+=1
echo !num! >log1.txt
%file1%
)
)

Jaka

  • Guest
Re: number of times started
« Reply #50 on: November 25, 2014, 04:33:07 AM »
sorry this still not working  :-\

Jaka

  • Guest
Re: number of times started
« Reply #51 on: November 28, 2014, 09:27:05 AM »
Can someone please help me to repair this script, please?  :(

foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: number of times started
« Reply #52 on: November 28, 2014, 09:31:07 AM »
Just repeating myself here: for someone to give you a script that works reliably then you have to tell them exactly what the task is.
That means the programs being used, and what the aim of the task is, and the directories being used and the operating system etc.


patio

  • Moderator


  • Genius
  • Maud' Dib
  • Thanked: 1769
    • Yes
  • Experience: Beginner
  • OS: Windows 7
Re: number of times started
« Reply #53 on: November 28, 2014, 09:33:50 AM »
That comes on Page 7...
" Anyone who goes to a psychiatrist should have his head examined. "

Jaka

  • Guest
Re: number of times started
« Reply #54 on: November 28, 2014, 09:37:09 AM »
Just repeating myself here: for someone to give you a script that works reliably then you have to tell them exactly what the task is.
That means the programs being used, and what the aim of the task is, and the directories being used and the operating system etc.

I did it on page 3.
Is this not enough? What I should do more? Can you help me explain how to do it than, please?

our scheduled task will fire.
The batch file will check if stop.txt exist
If stop.txt exist, nothing happends
if stop.txt not exist it will proceed
The batch file will run file1.exe and write 1 to log1.txt
Your scheduled task will fire.
The batch file will run file1.exe and write 2 to log1.txt
Your scheduled task will fire.
The batch file will run file1.exe and write 3 to log1.txt
Your scheduled task will fire.
The batch file will run file1.exe and write 4 to log1.txt
Your scheduled task will fire.
The batch file will run file1.exe and write 5 to log1.txt
Your scheduled task will fire.
The batch file will run file2.exe and write 1 to log2.txt
Your scheduled task will fire.
The batch file will run file1.exe and write 1 to log1.txt
Your scheduled task will fire.
The batch file will run file1.exe and write 2 to log1.txt
Your scheduled task will fire.
The batch file will run file1.exe and write 3 to log1.txt
Your scheduled task will fire.
The batch file will run file1.exe and write 4 to log1.txt
Your scheduled task will fire.
The batch file will run file1.exe and write 5 to log1.txt
Your scheduled task will fire.
The batch file will run file2.exe and write 2 to log2.txt
Your scheduled task will fire.
The batch file will run file1.exe and write 1 to log1.txt
Your scheduled task will fire.
The batch file will run file1.exe and write 2 to log1.txt
Your scheduled task will fire.
The batch file will run file1.exe and write 3 to log1.txt
Your scheduled task will fire.
The batch file will run file1.exe and write 4 to log1.txt
Your scheduled task will fire.
The batch file will run file1.exe and write 5 to log1.txt
Your scheduled task will fire.
The batch file will run file2.exe and write 3 to log2.txt
The batch file will create stop.txt

foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: number of times started
« Reply #55 on: November 28, 2014, 09:40:48 AM »
.
« Last Edit: November 28, 2014, 09:51:21 AM by foxidrive »

foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: number of times started
« Reply #56 on: November 28, 2014, 09:50:57 AM »
Let me be clearer: nobody wants to help you because you purposely aren't describing the task.

Jaka

  • Guest
Re: number of times started
« Reply #57 on: November 28, 2014, 10:03:56 AM »
Just repeating myself here: for someone to give you a script that works reliably then you have to tell them exactly what the task is.
That means the programs being used, and what the aim of the task is, and the directories being used and the operating system etc.

I can't tell you which program because it is some old program for backup, it works on WIN XP. I can only give it to you.
Directories used is D:\backup\script there will be this batch too
backup folder where backup files are
E:\backup_daily\monday.atk

that batch file will be started by task scheduler every day and it will start file1.exe which check backup if exsist and if backup is missing it will restart program for backup, that is done with file1.exe
when program is restared 5 times than it should restart PC, that is flie2.exe and when PC is restarted than goes to backup program and when that cycle with restarting comes to 3 times for restart pc and 15 times for restart backup program it will stop all..

file1.exe is script which check if file monday.atk exist, if not than check running process of backup software, stop it and start it again.
file2.exe is just restart script


Jaka

  • Guest
Re: number of times started
« Reply #58 on: November 28, 2014, 10:05:03 AM »
Let me be clearer: nobody wants to help you because you purposely aren't describing the task.
I see that, now I hope I manage to describe correctly.

patio

  • Moderator


  • Genius
  • Maud' Dib
  • Thanked: 1769
    • Yes
  • Experience: Beginner
  • OS: Windows 7
Re: number of times started
« Reply #59 on: November 28, 2014, 10:20:48 AM »
How can you not know what program it is ? ?

" Anyone who goes to a psychiatrist should have his head examined. "