View unanswered posts | View active topics It is currently 23 Nov 2014 20:33



Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Relative date to start a scheduled task 
Author Message

Joined: 08 Jul 2012 21:00
Posts: 13
Post Relative date to start a scheduled task
Hello everyone! Image

I'm looking for a batch script that would schedule a task to start 40 days from now (so, it is a relative date).

It should be language independent and compatible with XP/Vista/2008/7, x86 and x64.

Any help would be greatly appreciated!

Image


08 Jul 2012 21:08
Profile

Joined: 10 Feb 2012 02:20
Posts: 4412
Post Re: Relative date to start a scheduled task
VBS can get a date 40 days hence

The AT.EXE command might be able to take a date.


Code:
:: Date foward & backward
@echo off
:: from code by Phil Robyn
setlocal
if [%1]==[] (
  echo to get todays date use
  echo call "%~n0" today 0
  echo.
  echo to get yesterdays date use
  echo call "%~n0" today -1
  echo.
  echo to get the date 25 days ago:
  echo call "%~n0" today -25
  echo.
  echo to get the date 1250 days in the future
  echo call "%~n0" today +1250
  goto :EOF)

set date1=%1
set qty=%2
if /i "%date1%" EQU "TODAY" (
 set date1=now
) else (
 set date1="%date1%"
)
echo >"%temp%\%~n0.vbs" s=DateAdd("d",%qty%,%date1%)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^&_
echo>>"%temp%\%~n0.vbs"         right(100+month(s),2)^&_
echo>>"%temp%\%~n0.vbs"         right(100+day(s),2)
for /f %%a in (
  'cscript //nologo "%temp%\%~n0.vbs"') do set result=%%a
del "%temp%\%~n0.vbs"
endlocal& set day=%result:~0,4%-%result:~4,2%-%result:~6,2%
echo %%day%% is set to "%day%" (without the quotes)


09 Jul 2012 00:25
Profile
Expert

Joined: 06 Dec 2011 22:15
Posts: 775
Location: México City, México
Post Re: Relative date to start a scheduled task
You may use my StdDate.exe program to get the future date in a very easy way:
Code:
StdDate > NUL
set /A future=%errorlevel%+40
StdDate %future%


09 Jul 2012 08:46
Profile

Joined: 08 Jul 2012 21:00
Posts: 13
Post Re: Relative date to start a scheduled task
Hello, when I try to use the HexToBin it generates a StdDate.exe of 0 bytes...

What could be wrong?

Image

Aacini wrote:
You may use my StdDate.exe program to get the future date in a very easy way:
Code:
StdDate > NUL
set /A future=%errorlevel%+40
StdDate %future%


09 Jul 2012 11:35
Profile
Expert

Joined: 06 Dec 2011 22:15
Posts: 775
Location: México City, México
Post Re: Relative date to start a scheduled task
I don't know. Did you also copied HexChar.vbs file?
Code:
>dir
 Volume in drive C has no label.
 Volume Serial Number is CCA1-5338

 Directory of C:\Documents and Settings\Antonio\My Documents\ASMB\Batch File Programming\tests\test

09/07/2012  05:20 p.m.    <DIR>          .
09/07/2012  05:20 p.m.    <DIR>          ..
09/07/2012  05:21 p.m.               686 HexChar.vbs
09/07/2012  05:20 p.m.               515 HexToBin.bat
09/07/2012  05:18 p.m.             2,881 StdDate.exe.hex
               3 File(s)          4,082 bytes
               2 Dir(s)   1,856,012,288 bytes free

C:\Documents and Settings\Antonio\My Documents\ASMB\Batch File Programming\tests\test
>hextobin StdDate.exe.hex
StdDate.exe file created
C:\Documents and Settings\Antonio\My Documents\ASMB\Batch File Programming\tests\test
>dir
 Volume in drive C has no label.
 Volume Serial Number is CCA1-5338

 Directory of C:\Documents and Settings\Antonio\My Documents\ASMB\Batch File Programming\tests\test

09/07/2012  05:21 p.m.    <DIR>          .
09/07/2012  05:21 p.m.    <DIR>          ..
09/07/2012  05:21 p.m.               686 HexChar.vbs
09/07/2012  05:20 p.m.               515 HexToBin.bat
09/07/2012  05:21 p.m.             3,072 StdDate.exe
09/07/2012  05:18 p.m.             2,881 StdDate.exe.hex
               4 File(s)          7,154 bytes
               2 Dir(s)   1,856,008,192 bytes free


09 Jul 2012 16:29
Profile

Joined: 10 Feb 2012 02:20
Posts: 4412
Post Re: Relative date to start a scheduled task
Aacini, you could have a single post with one batch file that creates all your utilities. Make it easy for people and they will use them.

I suggested this before and you ignored me: I know that it's a PITA trying to extract the information for one tool, let alone all of them - and you're making it hard for people to use all your tools. That's illogical, if you want your programs to become widely used.

After all - this is a batch file site and we use batch file to make our tasks easier. What better way is there to create all your tools in one hit?


09 Jul 2012 17:51
Profile

Joined: 08 Jul 2012 21:00
Posts: 13
Post Re: Relative date to start a scheduled task
I was missing the .vbs. It worked perfectly Image but how could I set a variable with StdDate result on the same batch?

Thank you for taking the time to write all those tools. Small, fast, compatible and really helpful.


Image & Image

Image


09 Jul 2012 20:39
Profile
Expert

Joined: 06 Dec 2011 22:15
Posts: 775
Location: México City, México
Post Re: Relative date to start a scheduled task
david.lynch wrote:
... how could I set a variable with StdDate result on the same batch?

Use a FOR /F command this way:
Code:
StdDate > NUL
set /A future=%errorlevel%+40
for /F %%a in ('StdDate %future%') do set futureDate=%%a


Antonio


10 Jul 2012 07:43
Profile

Joined: 08 Jul 2012 21:00
Posts: 13
Post Re: Relative date to start a scheduled task
Great! Image

Image


10 Jul 2012 08:47
Profile
Expert

Joined: 06 Dec 2011 22:15
Posts: 775
Location: México City, México
Post Re: Relative date to start a scheduled task
foxidrive wrote:
... you're making it hard for people to use all your tools.

I don't think so. David just misread the beginning of the explanation about how to create my .exe auxiliary programs:
Aacini wrote:
NOTE: If you want to convert a filename.exe.hex file to filename.exe, just copy both HexToBin.bat and HexChar.vbs files below, and type: hextobin filename.exe.hex


foxidrive wrote:
Aacini, you could have a single post with one batch file that creates all your utilities...

I suggested this before and you ignored me: I know that it's a PITA trying to extract the information for one tool...

After all - this is a batch file site and we use batch file to make our tasks easier. What better way is there to create all your tools in one hit?


You should realize that each one of these programs have its own description and examples, and its number increase as I release they. I think it will be harder for people to download the complete set of programs, descriptions and examples if they just want one program! The example of that is David in this topic: why he should download a file about 15 times larger if he just wanted to use StdDate program?

What is needed is an index at the beginning of that topic so people may quickly browse the auxiliary programs and easily locate the specific one(s) they wants. I will post that index soon.

However, if your concerns about "Make it easy for people ... use" my programs are genuine and not just an opportunity to criticize (that you are prone to), why you don't write the Batch file you suggested yourself? As you know, write that Batch file is easy: you just need to compile the information I posted in two topics! This way, the Batch file will be completed in exactly the way you want. So?

Antonio

PS - I apologize for "ignored you" in the past, but I was very busy writting the auxiliary programs...


10 Jul 2012 09:48
Profile

Joined: 23 Dec 2011 13:59
Posts: 2008
Post Re: Relative date to start a scheduled task
Slightly off topic but some what related to Foxi's point, I use a utility called Swiss File Knife. It is one single command line utility that does a whole lot of tasks. It combines many functions into a single executable. You could do the same with all your utilities.

http://stahlworks.com/dev/swiss-file-knife.html


10 Jul 2012 11:25
Profile
Expert

Joined: 06 Dec 2011 22:15
Posts: 775
Location: México City, México
Post Re: Relative date to start a scheduled task
That is precisely the opposite point of view of my program design! If you read my previous, old posts, perhaps you remember that I started these utilities with small .com executable files of a couple hundred bytes sizes. When I was forced to write Win32 .exe executable files, I complained about the new size of the same programs, about 1500-2000 bytes. Why is small size an important point here? Because Batch file execution is SLOW! If the auxiliary program is large, then Batch programs like Mandelbrot Set in color or the animated game Snake, that execute the auxiliary file hundred or thousand times, would be just too slow to be useful...

EDIT: As a matter of fact, in my opinion the only way that Batch may achieve some tasks normally deserved to any other real programming language is by trying to write Batch programs that run in the fastest possible way, and the only way to do that with additional Batch features is via the smallest possible auxiliary files!


10 Jul 2012 12:37
Profile

Joined: 08 Jul 2012 21:00
Posts: 13
Post Re: Relative date to start a scheduled task
Aacini wrote:
David just misread the beginning of the explanation about how to create my .exe auxiliary programs:


That's true, I was really tired, almost sleeping on the PC Image

Aacini wrote:
What is needed is an index at the beginning of that topic so people may quickly browse the auxiliary programs and easily locate the specific one(s) they wants. I will post that index soon.


I agree!

Please keep your tools coming. Great work, and it is appreciated Image

Peace!


10 Jul 2012 12:50
Profile

Joined: 23 Dec 2011 13:59
Posts: 2008
Post Re: Relative date to start a scheduled task
Aacini wrote:
That is precisely the opposite point of view of my program design! If you read my previous, old posts, perhaps you remember that I started these utilities with small .com executable files of a couple hundred bytes sizes. When I was forced to write Win32 .exe executable files, I complained about the new size of the same programs, about 1500-2000 bytes. Why is small size an important point here? Because Batch file execution is SLOW! If the auxiliary program is large, then Batch programs like Mandelbrot Set in color or the animated game Snake, that execute the auxiliary file hundred or thousand times, would be just too slow to be useful...

EDIT: As a matter of fact, in my opinion the only way that Batch may achieve some tasks normally deserved to any other real programming language is by trying to write Batch programs that run in the fastest possible way, and the only way to do that with additional Batch features is via the smallest possible auxiliary files!

Well Swiss File Knife is so small it fits on a Floppy Disk and has about 90 utilities built-in to it. And it is wicked fast at doing some of the Large Data Processing I need it to do. I used to have a pure batch solution for appending data to the end of each line in very large text files. Pure batch was extremely slow but SFK was super fast at doing it.

I was just making an observation based on my experience with another piece of software.


10 Jul 2012 13:09
Profile
Expert

Joined: 06 Dec 2011 22:15
Posts: 775
Location: México City, México
Post Re: Relative date to start a scheduled task
Squashman wrote:
Well Swiss File Knife is so small it fits on a Floppy Disk and has about 90 utilities built-in to it. And it is wicked fast at doing some of the Large Data Processing I need it to do. I used to have a pure batch solution for appending data to the end of each line in very large text files. Pure batch was extremely slow but SFK was super fast at doing it.

I was just making an observation based on my experience with another piece of software.


Yes, my first answer was also based on what I think it would happen with a big program. It seems that the only way to answer this question is to do a simple test. Perhaps you may take one of the Batch files I mentioned above (Mandelbrot Set or Snake, or anyone you wish with heavy repetitive loops) and insert a simple call to Swiss File Knife (sfk > nul) in the innermost loop. If the additional running time is not significant, then the suggestion of grouping all my programs in one big file will seem a good idea (and I will thank you for it)!


10 Jul 2012 18:26
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next


Who is online

Users browsing this forum: Bing [Bot], Ed Dyreen, ShadowThief, Yahoo [Bot] and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forums/DivisionCore.