Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

CMD Batch: Get Time

- - - - -

  • Please log in to reply
17 replies to this topic

#1
Caml Light

Caml Light

    Junior

  • Member
  • Pip
  • 85 posts
  • Joined 03-October 03
Hi batchers! :hello:

I need to get the correct date from Internet (only the current day, month and year, not hours, minutes and seconds) Here there is a working AutoIt script, but i need to do it with a CMD batch...

http://www.autoitscr...-form-internet/

Thank you!


How to remove advertisement from MSFN

#2
CoffeeFiend

CoffeeFiend

    Coffee Aficionado

  • Super Moderator
  • 5,399 posts
  • Joined 14-July 04
  • OS:Windows 7 x64
  • Country: Country Flag
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.
Coffee: \ˈkȯ-fē, ˈkä-\. noun. Heaven in a cup. Life's only treasure. The meaning of life. Kaffee ist wunderbar. C8H10N4O2 FTW.

#3
allen2

allen2

    Not really Newbie

  • Member
  • PipPipPipPipPipPipPip
  • 1,814 posts
  • Joined 13-January 06
The variable %date% should do.

#4
CoffeeFiend

CoffeeFiend

    Coffee Aficionado

  • Super Moderator
  • 5,399 posts
  • Joined 14-July 04
  • OS:Windows 7 x64
  • Country: Country Flag

The variable %date% should do.

Not quite:

I need to get the correct date from Internet


Coffee: \ˈkȯ-fē, ˈkä-\. noun. Heaven in a cup. Life's only treasure. The meaning of life. Kaffee ist wunderbar. C8H10N4O2 FTW.

#5
Geej

Geej

    Senior Member

  • Member
  • PipPipPipPip
  • 635 posts
  • Joined 01-January 08
  • OS:XP Pro x86
  • Country: Country Flag
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, 06 October 2011 - 12:20 AM.


#6
allen2

allen2

    Not really Newbie

  • Member
  • PipPipPipPipPipPipPip
  • 1,814 posts
  • Joined 13-January 06
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.

#7
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,657 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag
Philosophical considerations set apart, here:

http://www.softpedia...t/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/...ne.cgi?UTC/s/0/
and parse it

jaclaz

#8
Caml Light

Caml Light

    Junior

  • Member
  • Pip
  • 85 posts
  • Joined 03-October 03
hi guys, thanks for your replies! I need it to protect my software. So, what's the best method for you?

#9
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,657 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag

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....wiki/Jack_(tree)
(or "mango" for that matters), let alone "Jack Robinson":
http://en.wikipedia....mythical_person)

:lol:

jaclaz

#10
Caml Light

Caml Light

    Junior

  • Member
  • Pip
  • 85 posts
  • Joined 03-October 03
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)?

#11
CoffeeFiend

CoffeeFiend

    Coffee Aficionado

  • Super Moderator
  • 5,399 posts
  • Joined 14-July 04
  • OS:Windows 7 x64
  • Country: Country Flag

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...
Coffee: \ˈkȯ-fē, ˈkä-\. noun. Heaven in a cup. Life's only treasure. The meaning of life. Kaffee ist wunderbar. C8H10N4O2 FTW.

#12
Caml Light

Caml Light

    Junior

  • Member
  • Pip
  • 85 posts
  • Joined 03-October 03
Ok, i can forget batch files... but, what do you suggest me?

#13
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,657 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag
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:
  • there is NO "UNcrackable" software protection based on software[1]
  • there is NOT EVEN ANY "UNcrackable" software protection based on hardware[1]
  • having the app checking from a batch (or any plain-text interpreted language) a date on the internet is VERY EASILY crackable
  • 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....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

#14
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,421 posts
  • Joined 02-August 03
  • OS:none specified
  • Country: Country Flag

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 .


GunSmokingMan



#15
allen2

allen2

    Not really Newbie

  • Member
  • PipPipPipPipPipPipPip
  • 1,814 posts
  • Joined 13-January 06
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.

#16
CoffeeFiend

CoffeeFiend

    Coffee Aficionado

  • Super Moderator
  • 5,399 posts
  • Joined 14-July 04
  • OS:Windows 7 x64
  • Country: Country Flag

but, what do you suggest me?

You mean, totally without knowing what you're trying to do or for what purpose, your skill level (with computers in general, or at scripting/programming) , languages you might know, your preferences, what resources (time, money or otherwise) are available, who the end user is, what platform(s) it should run onto, performance goals you might have, what support you may need, features you require, etc?

I might as well recommend a banana then. That's the thing with guessing based on no information whatsoever. The results tend to suck.

It's a bit like asking "pick a vehicle for me", without knowing if it needs to fly, float, carry cargo, budget limits or anything like that. You need a bit of infos first, before you can actually make any sensible recommendations.

Not even knowing what kind of thing it's meant to protect I'm not sure you're not totally wasting your time in the first place. It could be something as trivial as this for all we know, which TONS of people could easily write from scratch in a variety of languages in less than 5 minutes anyway (or perhaps find other tools that do the same thing but without restrictions). There's no point in even wasting time protecting something simple like that. Then again, I have absolutely no idea what you're working onto here so I might be completely off.
Coffee: \ˈkȯ-fē, ˈkä-\. noun. Heaven in a cup. Life's only treasure. The meaning of life. Kaffee ist wunderbar. C8H10N4O2 FTW.

#17
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,657 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag

I might as well recommend a banana then.

Suddenly....
Spoiler


:lol:

jaclaz

#18
tguy

tguy

    Senior Member

  • Member
  • PipPipPipPip
  • 698 posts
  • Joined 19-May 04
I would assume you are running a version of Windows server for your software registration process so if that's the case, depending on the version of Windows Server you are running; I would look into using the following:

net time /setsntp:pool.ntp.org

or W32TM as was mentioned in an earlier thread here. Either will work just make sure your firewall is set to allow UDP traffic port 123.

Good luck.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users