Pc Date control within batchfile

May 29, 2009 at 08:50:50
Specs: Windows XP SP2, intel
Hi all,
I am working on a batch file which comprises a Call statement to execute an application. This application only starts if the date is set to a certain date.
Right before my call statement, I save the actual date then I set it to the desired one. After the Call statement, I set it back. No problem up to here.
I am trying to find a simple way to restore the date right after the application has started so that the files saved by the application have the proper date!
Thank you for your hints!
greeds,
Lin

See More: Pc Date control within batchfile

Report •


#1
May 29, 2009 at 09:15:39
Didn't we go through this a couple days ago?


=====================================
If at first you don't succeed, you're about average.

M2


Report •

#2
May 29, 2009 at 12:50:27
I have found a couple of methods to change date and time but i coulnd find anything helpfull for my problem.
The problem here is that in my batchfile the proper date is restored only after the end of the application execution.
the time should be restored right after the Call comand and during the application execution.
If this has already been discussed i apologize for posting a similar question. In this case you could post a link to this discussion.

Report •

#3
May 29, 2009 at 13:01:53
For starters, you don't call an application. CALL is for batch files.

set DSAV=%DATE%
set TSAV=%TIME%
start MYAPP.exe
set date=%DSAV%
set time=%TSAV%


=====================================
If at first you don't succeed, you're about average.

M2


Report •

Related Solutions

#4
May 29, 2009 at 14:19:25
This is exactly what i am using for changing date and time.
the crucial part looks like that.

set x=%DATE%
set date=%01%_%01%_%1999%
Call program (arguments)
set date=%x%

like that, the proper time is set when "program" has finisched. I want the wrong date only for the instant when "program" is lounched.
Now, all files saved during "program" is running are saved on 01/01/1999!

Hope you understood the problem!


Report •

#5
May 29, 2009 at 14:41:34
Yep, I did.


=====================================
If at first you don't succeed, you're about average.

M2


Report •

#6
May 29, 2009 at 14:52:30
I think file creation dates depend on the system date. Will your application execute using the local var? Will this, or a variation, work for you?

@echo off
cls
setlocal

set date=01_01_1999
start applic (arguments)

endlocal


Report •

#7
May 29, 2009 at 16:31:50
Only reason I can see you going thru this exercise is to use a program you can't use anymore because it was date coded to expire.

Technically you can't use this software legally any more if this is the case.


Report •

#8
June 2, 2009 at 22:56:05
@Valerie
unfortunatly my application seems to use date as a global variable, but thanks for this good idea.
@Wanderer
This is actually the point! I have several versions of this sofware including the actual one with license, but an older version revealed itself to fit best to the problem.

probably the problem can be solved with something like this:

start batch1
start batch2

**********
batch 1:

sleep -m 10
call program (arguments)

**********
batch2:

set x=%DATE%
set date=%01%_%01%_%1999%
sleep -m 20
set date=%x%

1. The sleep comand does not work in xp. How to specify time in ms with "ping localhost -n 7 >nul" ?
2. The process is still not working, any idea?


Report •

#9
June 2, 2009 at 23:13:38
Process works:

code:
start batch1
start batch2

****
batch1:
set saved=%DATE%
Echo 01/01/2004 |Date
ping localhost -n 2 >nul
Echo %saved% |Date

*****
batch2
ping localhost -n 1 >nul
call MyApp testX.dat

This variation is fine if Myapp is called once. If it has to be called more than one time i have to find another way...
any suggestions?


Report •


Ask Question