Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Can i create a batch that ends at a specific date which means it will be a trial  (Read 14570 times)

0 Members and 1 Guest are viewing this topic.

Abo-Zead

    Topic Starter


    Beginner
  • Thanked: 1
  • Experience: Familiar
  • OS: Windows 10
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

Hackoo



    Hopeful
  • Thanked: 42
  • Experience: Expert
  • OS: Windows 10
I think this question can be found here : How to set an expiration date on a batch file?

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
« Last Edit: December 31, 2020, 01:10:52 PM by Hackoo »

Abo-Zead

    Topic Starter


    Beginner
  • Thanked: 1
  • Experience: Familiar
  • OS: Windows 10
Thanks, Hackoo

You always help me better .

DaveLembke



    Sage
  • Thanked: 662
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
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.

Abo-Zead

    Topic Starter


    Beginner
  • Thanked: 1
  • Experience: Familiar
  • OS: Windows 10
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

Squashman



    Specialist
  • Thanked: 134
  • Experience: Experienced
  • OS: Other
I highly recommend using Dave Benham's Obfuscate Batch instead of the Bat to Exe files that really don't hide anything.

Abo-Zead

    Topic Starter


    Beginner
  • Thanked: 1
  • Experience: Familiar
  • OS: Windows 10
I highly recommend using Dave Benham's Obfuscate Batch 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?

Squashman



    Specialist
  • Thanked: 134
  • Experience: Experienced
  • OS: Other

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.