• Announcements

    • xper

      MSFN Sponsorship and AdBlockers!   07/10/2016

      Dear members, MSFN is made available via subscriptions, donations and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, become a site sponsor and ads will be disabled automatically and by subscribing you get other sponsor benefits.
tomasz86

How to get around the 2047 characters CMD string limitation

36 posts in this topic

I came up with both of those about 2 and a half years ago. For Date, you are correct that the core of the code is essentially a reformatting of Rob's SortDate Version 3.10, which is why he is given specific credit, with the only change really being in the added output of the individual components in addition to the combined date string. (I never really saw the advantage of Rob's Version 4 of SortDate.) Time did not come from any version of Rob's SortTime code at all. (The core code for it came from ss64.com as credited, including the comment about the guy with green ink. LOL) I guess really the shortest solution to get both date and time is Rob's SortDate Version 5.

Cheers and Regards

Edited by bphlpt
0

Share this post


Link to post
Share on other sites

I guess really the shortest solution to get both date and time is Rob's SortDate Version 5.

Yep :), but that, as already posted, only applies to XP and later.

The shortest version (in XP) is using the WMIC approach, the shortest for 2K (as I see it) is something *like*:

@ECHO OFF
SETLOCAL
cd.>datefile.$
FOR /F "tokens=1,2 delims= " %%A IN ('dir datefile.$ ^| FIND "datefile.$"') DO SET my_date=%%A & SET my_time=%%B
del datefile.$
set my_

but it misses seconds (and of course it is only useful to get rid of the "day of the week feature").

What could also work on 2K (haven't a test bed handy, so needs to be checked/tested) may be variable expansion:

 @ECHO OFF
SETLOCAL ENABLEEXTENSIONS
cd.>datefile.$
Call :do_date datefile.$
GOTO :EOF
:do_date
FOR /F "tokens=1,2 delims= " %%A IN ("%~t1") DO SET my_date=%%A & SET my_time=%%B
del datefile.$
set my_

jaclaz

0

Share this post


Link to post
Share on other sites

The great advantage of unix tools date is that you get easily and without hassle the date / time in almost whatever format you might imagine.

0

Share this post


Link to post
Share on other sites

And another difference.

2000 + CMD.exe(2000)

Microsoft Windows 2000 [Version5.0.2195]

2000 + CMD.exe(XP)

Microsoft Windows XP [Version5.0.2195]

XP + CMD.exe(XP)

Microsoft Windows XP [Version5.1.2600]

0

Share this post


Link to post
Share on other sites

The great advantage of unix tools date is that you get easily and without hassle the date / time in almost whatever format you might imagine.

Yep, but the point (mine) was to not use external programs.

There is also a debug script, that should work on 2K as well:

http://www.robvanderwoude.com/debug.php

Now, Today and Todaynow

jaclaz

0

Share this post


Link to post
Share on other sites

Never needed to use this means but if you go this way then you could also use something like the method used by Herbert Kleebauer there or like explained there to put any needed executable in the batch as some resource that would be extracted/decoded before being used.

0

Share this post


Link to post
Share on other sites

Never needed to use this means but if you go this way then you could also use something like the method used by Herbert Kleebauer there or like explained there to put any needed executable in the batch as some resource that would be extracted/decoded before being used.

Yes, of course :thumbup , though I personally tend to to use the simpler ECHOO.COM (also by Herbert Kleebauer):

for the little uses I need (which are usually connected to "dynamically produce some hex bytes).

I am really "old school" :ph34r: but I really see no issues in having an external tool and - whenever possible/advisable - I try not to "embed" anything inside "anything else", in which case the so-called "batch compilers" (which mostly - but not all ) do nothing but package the batch and the needed tools into a SFX archive, seem to me a better choice.

jaclaz

0

Share this post


Link to post
Share on other sites

For 2K (but also for XP if one wants to have the date/time format in the "full" UTC format), writing a file and immediately get it's created or last accessed time/date may be a good enough workaround :unsure:.

How about this as a workaround?

CD.>temp
cabarc n temp._ temp
FOR /F "skip=9 tokens=3-8 delims=/: " %%A IN ('cabarc l temp._') DO ECHO %%A%%B%%C.%%D%%E%%F

The result is same as using

date.exe +%%Y%%m%%d.%%H%%M%%S

0

Share this post


Link to post
Share on other sites

How about this as a workaround?

Which advantage has it when compared to the snippet in post #27 (that needs not cabarc or *any* external program)? :unsure:

The issue is that you need to create a file (in your case TWO of them).

jaclaz

0

Share this post


Link to post
Share on other sites

The advantage is that you also get seconds and that it's completely locale independent (you get hours in the 24-hour format).

0

Share this post


Link to post
Share on other sites

The advantage is that you also get seconds and that it's completely locale independent (you get hours in the 24-hour format).

Ah, well. :)

jaclaz

0

Share this post


Link to post
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.