Computer Hope

Microsoft => Microsoft DOS => Topic started by: Abo-Zead on December 31, 2020, 11:47:14 AM

Title: Can i create a batch that ends at a specific date which means it will be a trial
Post by: Abo-Zead on December 31, 2020, 11:47:14 AM
I want to create a bat file that will end at a specific date
The first idea I found is to store the current date inside the variable.
And store the expiration date inside another variable.
Then compare between the two dates and if they are equal it will display a Message then will exit from the batch.
but it didn't work.
Appreciate any help
Title: Re: Can i create a batch that ends at a specific date which means it will be a trial
Post by: Hackoo on December 31, 2020, 12:53:08 PM
I think this question can be found here : How to set an expiration date on a batch file? (https://stackoverflow.com/questions/53524132/how-to-set-an-expiration-date-on-a-batch-file?answertab=active#tab-top)

Try this. Example dates are used in the IF conditions in a format YYYYMMDD (you can set your own values) :
For the new year 2021 this batch dos not work any more  :D ;)

Code: [Select]
@echo off
Title EXPIRATION DATE WITH BATCH
for /f "tokens=* delims=" %%a in ('wmic os get LocalDateTime /value') do for /f "tokens=* delims=" %%# in ("%%a") do set "%%#"
set "LocalDateTime=%LocalDateTime:~0,8%"
REM echo %LocalDateTime%
:: EXPIRATION DATE ::
set "EXP_DATE=20201231"
:::::::::::::::::::::

if %LocalDateTime% GTR %EXP_DATE% (
color 0C
echo this wont work anymore
Timeout /t 5 /NoBreak >NUL
exit /b
)

START "" "Chrome"
Exit

Happy New Year 2021  ;) ;D
Title: Re: Can i create a batch that ends at a specific date which means it will be a trial
Post by: Abo-Zead on January 03, 2021, 01:01:42 AM
Thanks, Hackoo

You always help me better .
Title: Re: Can i create a batch that ends at a specific date which means it will be a trial
Post by: DaveLembke on January 03, 2021, 02:21:36 PM
Just a FYI... anyone who knows how to open the batch file in notepad etc can extend the date that it expires or remove the expiration completely! Only way around this would be to compile it to protect it from editing. There was a Batch to EXE compiler years ago, but I haven't messed with that in ages to say how strong it is to protecting contents from view or alteration when in EXE form.
Title: Re: Can i create a batch that ends at a specific date which means it will be a trial
Post by: Abo-Zead on January 04, 2021, 08:24:34 PM
Just a FYI... anyone who knows how to open the batch file in notepad etc can extend the date that it expires or remove the expiration completely! Only way around this would be to compile it to protect it from editing. There was a Batch to EXE compiler years ago, but I haven't messed with that in ages to say how strong it is to protecting contents from view or alteration when in EXE form.

Thanks, DaveLembke

I already found some programs to compile my batch from any manipulate content
but also thanks for your reminder
Title: Re: Can i create a batch that ends at a specific date which means it will be a trial
Post by: Squashman on March 30, 2021, 09:30:10 AM
I highly recommend using Dave Benham's Obfuscate Batch (https://www.dostips.com/forum/viewtopic.php?f=3&t=7990&start=15#p53278) instead of the Bat to Exe files that really don't hide anything.
Title: Re: Can i create a batch that ends at a specific date which means it will be a trial
Post by: Abo-Zead on April 11, 2021, 06:05:01 PM
I highly recommend using Dave Benham's Obfuscate Batch (https://www.dostips.com/forum/viewtopic.php?f=3&t=7990&start=15#p53278) instead of the Bat to Exe files that really don't hide anything.


Thanks, Squashman for your assistance and What is the difference between Dave Benham's Obfuscate Batch and the normal converter? Or Do you mean that we can use this batch as an intermediate step between my bat file and the conversion step?
Title: Re: Can i create a batch that ends at a specific date which means it will be a trial
Post by: Squashman on April 13, 2021, 12:45:45 PM

Thanks, Squashman for your assistance and What is the difference between Dave Benham's Obfuscate Batch and the normal converter? Or Do you mean that we can use this batch as an intermediate step between my bat file and the conversion step?
Bat to EXE converters are not compiled.  They are a self extracting executable.  It extracts the contents of the program to a temporary folder and then executes the batch file. Not hard to find for any remotely computer savvy person.

Dave's Obfuscation code keeps the bat file as a bat file but in a pseudo encrypted format.  While it is possible to decrypt the bat file it will take a bit of thinking or brute force to do so.  Dave and I had a discussion about keeping the encryption key separate from the batch file itself and we did a proof of concept on that as well.  Sort of like need for the private key of a pgp pair.  If you don't have the decryption code you would have even a more difficult time decrypting the batch file.