BATCH script to save DATE to a variable (Users)
> The line starts with "Current", so when GO.BAT is run, it runs that.
Thank you!
That's so obvious, how didn't I notice it?
> I would suggest using a FOR command to shorten these two lines into one:
> for %%a in (current go) do if exist %%a.bat del %%a.bat
Thanks for this!
> Many DOS shells already provide this. What particular environment(s) are
> you targeting?
I mainly use DOS 7.1 and 6.22 with the standard shell. I use FreeDOS too but not for this.
There's a freeware diagnostics program, NSSI, that I run on different computers while testing them, that is hard coded to print an error message if the current date is past 2008.
So with my script I save the current date, set the date as 12-31-2008, run the program, and then set the correct date again.
> I appreciate the minimalist approach, but perhaps a simple debug script or assembly tool would be cleaner. (Or even using REXX or 4DOS.)
Using assembly is probably a better way to do this, I agree. But it's out of my capabilities (at least for now). So your code is nothing short of black magic for me.
I compiled it and it prints the date this way:
Sat Mar 01,2025
But it doesn't create the DATE_ variable.
Could you please tweak your code so that it saves its content to the variable DATE_ with the date in this format MM-DD-YYYY? That's the format I need to use in my script to set the current date with the DATE command.
Is it possible to create/set a variable (the same way the SET command does) with an assembly program? Could you please give an example of assembly code that sets this environmental variable FOO=BAR? Just to try to understand it better.
If you can recommend any reading material on assembly for beginners that'd be great.
Complete thread:
- BATCH script to save DATE to a variable - tauro, 01.03.2025, 04:19 (Users)
- BATCH script to save DATE to a variable - Rugxulo, 01.03.2025, 08:14
- BATCH script to save DATE to a variable - ecm, 01.03.2025, 12:15
- BATCH script to save DATE to a variable - marcov, 01.03.2025, 12:45
- BATCH script to save DATE to a variable - tauro, 02.03.2025, 02:16
- BATCH script to save DATE to a variable - Rugxulo, 02.03.2025, 03:26
- BATCH script to save DATE to a variable - RayeR, 25.03.2025, 05:44
- BATCH script to save DATE to a variable - rr, 25.03.2025, 18:41
- BATCH script to save DATE to a variable - Rugxulo, 01.03.2025, 18:43
- BATCH script to save DATE to a variable - rosegondon, 02.03.2025, 17:10
- BATCH script to save DATE to a variable - Rugxulo, 01.03.2025, 08:14