Jump to content

CMD Batch: Get Time


Recommended Posts


At some point you have to realize batch files are 1980's best (MS-DOS era technology, before Windows even existed) and as such are severely limited. It's much easier to do this kind of stuff using any other language or scripting language. For starters, batch files don't have a native way to scrape web pages like that, and it's also quite a pain dealing with dates in batch files due to regional formatting differences. At some point you're better off moving to a more modern technology than batch files.

Link to comment
Share on other sites

Compile your autoit script as console application so as to interact with whatever batch command you have in mind.

Why need to do it with a CMD batch....?

Edited by Geej
Link to comment
Share on other sites

Indeed i was wrong and to make it in pure batch would need external exe (at least wget or equivalent ) and Geej is right about compile the autoit as console if needed (as the autoit code is only a function, you'll need to add the output part that will call the function).

Also i don't understand at all why you'd want to get the date from internet (and if it's for a software protection of some kind, this won't be reliable at all as everyone can just add nist.time.gov in their hosts file and create a fake web page with any date) and making it in batch would only make it weaker.

Link to comment
Share on other sites

Philosophical considerations set apart, here:

http://www.softpedia.com/get/Desktop-Enhancements/Clocks-Time-Management/Cmdtime.shtml

(already invented wheel)

Or check the use of W32TM.EXE....

Also, it depends on the accuracy you need/want, since you want "day" resolution you can use also httpget.:

http://www.willus.com/archive/

or curl or wget and download a page such as:

http://www.time.gov/timezone.cgi?UTC/s/0/

and parse it

jaclaz

Link to comment
Share on other sites

hi guys, thanks for your replies! I need it to protect my software. So, what's the best method for you?

If your "software" (or it's protection method) is written in batch (or any plain text, interpreted language) a five years old, blind-folded and with BOTH arms tied behind his/her back can crack it faster than you can say "Jack":

http://en.wikipedia.org/wiki/Jack_(tree)

(or "mango" for that matters), let alone "Jack Robinson":

http://en.wikipedia.org/wiki/Jack_Robinson_(mythical_person)

:lol:

jaclaz

Link to comment
Share on other sites

thank you for your sarcarm :), but i need a method to block my software after a period of time. I can use a text file on my server to check the expiration time, but it works only if the date on the computer that runs my software is correct.

Any ideas (not sarcastic)?

Link to comment
Share on other sites

thank you for your sarcarm

Yet, there's insight hiding in there. A protection written in batch will only get in the way of complete n00bs.

Any ideas (not sarcastic)?

I might be repeating myself here, but I'd start by not using batch files. Then again it's very easy recreating whatever a batch file can accomplish from scratch (in a few minutes) so I wouldn't worry so much about protecting it in the first place. Your call...

Link to comment
Share on other sites

As CoffeeFiend hinted, I masked with sarcasm some IMHO good advice, which (the advice I mean, not the joking remark I made) should be taken SERIOUSLY .

Now, the following are facts:

  1. there is NO "UNcrackable" software protection based on software[1]
  2. there is NOT EVEN ANY "UNcrackable" software protection based on hardware[1]
  3. having the app checking from a batch (or any plain-text interpreted language) a date on the internet is VERY EASILY crackable
  4. having the app sending a "challenge code" (encrypted) to a given site in order to receive an (encrypted) "authentication code" might seem a better idea, but it is NOT (generally speaking) a very good idea[2]

[1] It all depends on how valuable is your software and the amount of time and resources one is willing to dedicate to it's cracking. (ANYTHING created by man can be re-created by another man)

[2] Say that you have a (temporary) failure (of *any* kind) of your server, guess WHICH software your customers will decide to throw in the dumpbin as soon as they find out that the software they bought isn't working when they need it? Are you prepared to deal with a few tens/hundreds/thousands/zillions angry customers?

Of course if you don't care about your customers' satisfaction with your software, go ahead with your "server" approach. :thumbup

There are companies that make money by selling to other developers a protection tool, software, or hardware, or Internet based (which BTW is regularly cracked, sooner or later, at each release), do you really think you can do something better than that? (and with batch files? :w00t:)

BTW, if you think so, you are wrong :ph34r:, by definition of CATCH22:

http://en.wikipedia.org/wiki/Catch-22_(logic)

  • If you know how to create a safe protection, you don't ask for help on a forum about it..
  • If you ask for help on a forum about it you don't know how to create it.

MInd you I am not trying to put you down or anything like that :), I am simply trying to help you being in contact with reality.

jaclaz

Link to comment
Share on other sites

Ok, i can forget batch files... but, what do you suggest me?

There are a variety of programming langauges that you could use.

Myself I can write in VBS and Vb.net ok, understand Java Script

You could also do a Google or Bing Search in C programming .

Link to comment
Share on other sites

Nowadays the only good protections are online one's and without any executable available on the client side and this is a little expensive to setup but not really complex:

- you setup a secured/hardened server

- configure your application on this server with any protection or a minimal one (like checking the partition signature).

- allow users with very restricted rights to access and run your application on the server.

The worst case could be that someone find a way to hack your server.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...