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

How to get around the 2047 characters CMD string limitation

- - - - -

  • Please log in to reply
35 replies to this topic

#26
bphlpt

bphlpt

    MSFN Addict

  • Member
  • PipPipPipPipPipPipPip
  • 1,798 posts
  • OS:none specified
  • Country: Country Flag
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, 11 March 2013 - 09:26 AM.

Posted Image



How to remove advertisement from MSFN

#27
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,385 posts
  • OS:none specified
  • Country: Country Flag

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

#28
allen2

allen2

    Not really Newbie

  • Member
  • PipPipPipPipPipPipPip
  • 1,812 posts
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.

#29
blackwingcat

blackwingcat

    Friend of MSFN

  • Member
  • PipPipPipPipPip
  • 772 posts
  • OS:Windows 2000 Professional
  • Country: Country Flag
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]
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
BlackWingCat =^^=
http://blog.livedoor.jp/blackwingcat/
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

#30
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,385 posts
  • OS:none specified
  • Country: Country Flag

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.robvander...e.com/debug.php
Now, Today and Todaynow

jaclaz

#31
allen2

allen2

    Not really Newbie

  • Member
  • PipPipPipPipPipPipPip
  • 1,812 posts
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.

#32
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,385 posts
  • OS:none specified
  • Country: Country Flag

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):
http://reboot.pro/to...closed/?p=21795
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

#33
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,520 posts
  • OS:XP Pro x86
  • Country: Country Flag

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

Posted Image
Unofficial Service Pack 5.2 for MS Windows 2000 <- use this topic if you need help with UURollup, Update Rollup 2 and other unofficial packages

#34
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,385 posts
  • OS:none specified
  • Country: Country Flag

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

#35
tomasz86

tomasz86

    www.windows2000.tk

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,520 posts
  • OS:XP Pro x86
  • Country: Country Flag
The advantage is that you also get seconds and that it's completely locale independent (you get hours in the 24-hour format).
Posted Image
Unofficial Service Pack 5.2 for MS Windows 2000 <- use this topic if you need help with UURollup, Update Rollup 2 and other unofficial packages

#36
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,385 posts
  • OS:none specified
  • Country: Country Flag

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 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN