Computing.Net > Forums > Disk Operating System > bat for comparing date

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

bat for comparing date

Reply to Message Icon

Name: steverb
Date: January 26, 2005 at 21:11:16 Pacific
OS: XP
CPU/Ram: 2.8/512
Comment:

Hi,

I want to write a small bat file to read the current date of the computer and compare it with a preset date I put at the beginning of the bat file (for exampel: set mydate="wed 10/10/2005") and if these two dates are the same then delete a target file in c:\windows\system32\drivers\ directory.
I want to put this bat file in xp startup folder and every time computer boots up I want it to do this comparison. To protect the source bat file I need to do of the followings:

1. If date is the same as my preset date then after deleting target file in windows directory I want bat file also to be removed from startup folder of XP (probably need an expression to be loaded to registry).

2. convert bat to com or exe and put it in startup and in this case in case of two dates being same target file will be deleted and there is no need com/exe converted of bat file to be removed from startup since bat commands are not accessible.

I tried this for several days but couldn't do it. Could someone expert in bat writing please help me in writing a proper program and help finding procedure for one of the above options? Using bat2exec is not easy since all the time I get errores like "out of environmental space" or "can not load VDM IPX/SPX support".

Thanks
Steve




Sponsored Link
Ads by Google

Response Number 1
Name: jboy
Date: January 26, 2005 at 21:22:31 Pacific
Reply:

Have a look here - but also be advised that XP is not DOS based, and this is not really the best forum for your question


I'm not saying there should be a capital punishment for stupidity, but why don't we just take the safety labels off of everything and let the problem solve itself?


0

Response Number 2
Name: Mechanix2Go
Date: January 26, 2005 at 22:04:41 Pacific
Reply:

Hi Steve,

I'm not clear on what your trying to accomplish, beyong deleting a file based on a date comparison.

But first, you can cut your losses with bat2exe.

I've been messing with it on and off for years and it's useless for all but the most trivial of batch files.

And that's with "REAL" DOS. Which NT DOS-like services AIN'T.

Second, I don't know that it's such a great idea to automate the deletion of a file in in the system32 directory; or anywhere else in windows. But it's your computer.

If you're using a batch in XP/NT you can you the additonal power of NT. In this case:

%~tI - expands %I to date/time of file

With that, it's pretty straightforward to script a deletion based on date.

HTH

M2


0

Response Number 3
Name: steverb
Date: January 27, 2005 at 00:42:26 Pacific
Reply:

Thanks. I found ftp://garbo.uwasa.fi/pc/batchutil/pwrbt14j.zip which looks great. It has extra commands and accept dos bat commands too and has its own comiler (powermak) and makes exe file from bat like a dream. After spending about an hour reading it's documents and fixing syntax errors my exe now is ready and working fine. I recommend this program to whoever works with bat files very often and wants to make exe from them.

Steve


0

Response Number 4
Name: rogerashley
Date: January 27, 2005 at 00:49:20 Pacific
Reply:

Thanks for the response but it is still not
the correct forum for NT Command Prompt
Questions, this is after all a DOS forum!



0

Response Number 5
Name: Mechanix2Go
Date: January 27, 2005 at 01:16:01 Pacific
Reply:

Hi Steve,

That pwrbat compiler sounds goo. I'm trying to get it now.

As ever the challenge for a script wrietr is to get the thing done with no 3rd party utils, if making it available to others is a factor.

FWIW, in that same vein, I spent years in real DOS trying to get the date and time into environment varibles without using any external commands.

I never did figure it out, but discovered the trick by reading somebody else's cade.


M2


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: bat for comparing date

Dos Script to search for text www.computing.net/answers/dos/dos-script-to-search-for-text/13818.html

Making a file name include date www.computing.net/answers/dos/making-a-file-name-include-date/13859.html

date format in "prompt $d" www.computing.net/answers/dos/date-format-in-prompt-d/3881.html