36 posts in this topic

In Windows NT 4.0 and 2000 the maximum length of the string is only 2047 characters while in XP and 2003 it's 8191. In order to get around this you should just replace CMD.EXE in your system with the one from XP. I thought that there may be some other system files would have to be replaced too but no, replacing CMD.EXE is enough.

Of course having a line in batch longer than 2047 characters is very common, as an example, you cannot have this command:

DIR /B C:\a senselessly long directory name containing\another pretty much unusefully and stupidly named directory\which is nothing but a container for another directory that contains at least another directory\which in itself is a container\possibly the matrioschkas were not invented by the good Russian guys, but were originated in Poland\but actually the idea of a path is that of being easily accessible and normally the contents of a file goes inside it and not in it’s tiitle nor in the path to it\though of course everyone has his (or her) right to freedom I find it very rare than any NT4 or Win2K (please read as Windows 2000 Professional Edition or Windows 2000 Server Edition) user has ever seen in real life a longer than (say) 200 (at the most) command line – nor I have ever seen a command line tool that – when enclosing ALL available parameters and switches has ever reached that length – so all in all if you use absolute paths to call a tool that is residing on a 256 long path and having BOTH a source and target among it’s parameters – you manage to get at the most WHAT 800 characters – let’s double it to 1600 and you still have 400 + 47 characters before hitting this limit\just for your info at this point (including spaces) we are around 1300 characters before this backslash\so we can continue writing senseless directory names that noone will ever use (in his right mind) in real life if not to prove a completely senseless point about the max length of the command line that the NT and Win2K will be able to accept\you see I made my point in much less than 2047 characters so I have to continue writing this \I wonder why the good MS guys instead of saying it’s by design which is what they normally do on actually relevant bugs took instead the time to fix it – as I see it this happened only because they found this by chance in the source code of CMD.EXE and in order to get a pat on the shoulder or however make himself more visible the anonymous programmer which found it managed to make a bug submission and solve it

Share this post

Link to post

Share on other sites

Yep , the point being that if you want to "replace a string of text in a file", a tool designed to "replace a string of text in a file" often is more suited than using a "generic" (scriptable) command processor (as when using it, it may hit some limit or anyway take more time/resources than a, specific, dedicated, tool).

As you might well know, I do believe that the simplest solution (for simple problems) is a bunch of lines in a batch (and I do have my part of fun playing eith them batches), but when you are trying to do something that is not simple and you have a command line, specifically designed for the specific chore, external tool, then it's usually better to use it .

Share this post

Link to post

Share on other sites

I don't know but probably will work. I think I just enjoy playing around with these CMD scripts

In this particular case probably gsar will be indeed better as yesterday when I was running the script CMD.EXE ate up almost ~2GB of RAM

2 GB huh, lol, that must have been a bad memory pointer. VBS might be better for large string manipulation. MS officially states that REG.EXE cannot write binary values to the registry, but it can be done very reliably, example:

Share this post

Link to post

Share on other sites

@Phenomic, Sorry for the noob questions, but I don't quite get your example. After you define both r1 and r3, where/how are they used? Are they just used to set strValue? I guess I don't understand how the GetBinaryValue and SetBinaryValue work. Can you give me a pointer to a good tutorial?

BITS_DESCRIPTION="Transfers files in the background using idle network bandwidth. If the service is stopped, features such as Windows Update, and MSN Explorer will be unable to automatically download programs and other information. If this service is disabled, any services that explicitly depend on it may fail to transfer files if they do not have a fail safe mechanism to transfer files directly through IE in case BITS has been disabled."

gsar.exe -i -o -s"%BITS_DESCRIPTION%" -r"Transfers files in the background using idle network bandwidth. If the service is stopped, features such as Windows Update, and MSN Explorer will be unable to automatically download programs and other information. If this service is disabled, any services that explicitly depend on it may fail to transfer files if they do not have a fail safe mechanism to transfer files directly through IE in case BITS has been disabled." 1.inf

Edited March 6, 2013 by tomasz86

0

Share this post

Link to post

Share on other sites

gsar.exe -i -o -s"%BITS_DESCRIPTION%" -r"Transfers files in the background using idle network bandwidth.§My_append§"gsar.exe -i -o -s"§My_append§" -r" If the service is stopped, features such as Windows Update, and MSN Explorer will be unable to automatically download programs and other information.§My_append§"gsar.exe -i -o -s"§My_append§" -r"If this service is disabled, any services that explicitly depend on it may fail to transfer files if they do not have a fail safe mechanism to transfer files directly through IE in case BITS has been disabled." 1.inf