tomasz86 Posted October 11, 2012 Share Posted October 11, 2012 http://support.microsoft.com/kb/830473In 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.CMD.EXE 5.1.2600.5512from XP SP3 seems to work OK in Windows 2000 (no unofficial updates required). Link to comment Share on other sites More sharing options...
jaclaz Posted October 11, 2012 Share Posted October 11, 2012 In Windows NT 4.0 and 2000 the maximum length of the string is only 2047 characters ....Just in case:http://dictionary.reference.com/browse/onlyOf 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 itworking properly in NT and 2K. jaclaz Link to comment Share on other sites More sharing options...
tomasz86 Posted October 11, 2012 Author Share Posted October 11, 2012 I encountered this problem in "real life" and that's why I tried the CMD.EXE from XP and started this topic This is the line:HKLM,"SYSTEM\CurrentControlSet\Services\ServiceModelEndpoint 3.0.0.0\Performance","Counter Names",%REG_BINARY%,43,00,61,00,6c,00,6c,00,73,00,00,00,43,00,61,00,6c,00,6c,00,73,00,20,00,50,00,65,00,72,00,20,00,53,00,65,00,63,00,6f,00,6e,00,64,00,00,00,43,00,61,00,6c,00,6c,00,73,00,20,00,4f,00,75,00,74,00,73,00,74,00,61,00,6e,00,64,00,69,00,6e,00,67,00,00,00,43,00,61,00,6c,00,6c,00,73,00,20,00,46,00,61,00,69,00,6c,00,65,00,64,00,00,00,43,00,61,00,6c,00,6c,00,73,00,20,00,46,00,61,00,69,00,6c,00,65,00,64,00,20,00,50,00,65,00,72,00,20,00,53,00,65,00,63,00,6f,00,6e,00,64,00,00,00,43,00,61,00,6c,00,6c,00,73,00,20,00,46,00,61,00,75,00,6c,00,74,00,65,00,64,00,00,00,43,00,61,00,6c,00,6c,00,73,00,20,00,46,00,61,00,75,00,6c,00,74,00,65,00,64,00,20,00,50,00,65,00,72,00,20,00,53,00,65,00,63,00,6f,00,6e,00,64,00,00,00,43,00,61,00,6c,00,6c,00,73,00,20,00,44,00,75,00,72,00,61,00,74,00,69,00,6f,00,6e,00,00,00,43,00,61,00,6c,00,6c,00,73,00,20,00,44,00,75,00,72,00,61,00,74,00,69,00,6f,00,6e,00,20,00,42,00,61,00,73,00,65,00,00,00,54,00,72,00,61,00,6e,00,73,00,61,00,63,00,74,00,69,00,6f,00,6e,00,73,00,20,00,46,00,6c,00,6f,00,77,00,65,00,64,00,00,00,54,00,72,00,61,00,6e,00,73,00,61,00,63,00,74,00,69,00,6f,00,6e,00,73,00,20,00,46,00,6c,00,6f,00,77,00,65,00,64,00,20,00,50,00,65,00,72,00,20,00,53,00,65,00,63,00,6f,00,6e,00,64,00,00,00,53,00,65,00,63,00,75,00,72,00,69,00,74,00,79,00,20,00,56,00,61,00,6c,00,69,00,64,00,61,00,74,00,69,00,6f,00,6e,00,20,00,61,00,6e,00,64,00,20,00,41,00,75,00,74,00,68,00,65,00,6e,00,74,00,69,00,63,00,61,00,74,00,69,00,6f,00,6e,00,20,00,46,00,61,00,69,00,6c,00,75,00,72,00,65,00,73,00,00,00,53,00,65,00,63,00,75,00,72,00,69,00,74,00,79,00,20,00,56,00,61,00,6c,00,69,00,64,00,61,00,74,00,69,00,6f,00,6e,00,20,00,61,00,6e,00,64,00,20,00,41,00,75,00,74,00,68,00,65,00,6e,00,74,00,69,00,63,00,61,00,74,00,69,00,6f,00,6e,00,20,00,46,00,61,00,69,00,6c,00,75,00,72,00,65,00,73,00,20,00,50,00,65,00,72,00,20,00,53,00,65,00,63,00,6f,00,6e,00,64,00,00,00,53,00,65,00,63,00,75,00,72,00,69,00,74,00,79,00,20,00,43,00,61,00,6c,00,6c,00,73,00,20,00,4e,00,6f,00,74,00,20,00,41,00,75,00,74,00,68,00,6f,00,72,00,69,00,7a,00,65,00,64,00,00,00,53,00,65,00,63,00,75,00,72,00,69,00,74,00,79,00,20,00,43,00,61,00,6c,00,6c,00,73,00,20,00,4e,00,6f,00,74,00,20,00,41,00,75,00,74,00,68,00,6f,00,72,00,69,00,7a,00,65,00,64,00,20,00,50,00,65,00,72,00,20,00,53,00,65,00,63,00,6f,00,6e,00,64,00,00,00,52,00,65,00,6c,00,69,00,61,00,62,00,6c,00,65,00,20,00,4d,00,65,00,73,00,73,00,61,00,67,00,69,00,6e,00,67,00,20,00,53,00,65,00,73,00,73,00,69,00,6f,00,6e,00,73,00,20,00,46,00,61,00,75,00,6c,00,74,00,65,00,64,00,00,00,52,00,65,00,6c,00,69,00,61,00,62,00,6c,00,65,00,20,00,4d,00,65,00,73,00,73,00,61,00,67,00,69,00,6e,00,67,00,20,00,53,00,65,00,73,00,73,00,69,00,6f,00,6e,00,73,00,20,00,46,00,61,00,75,00,6c,00,74,00,65,00,64,00,20,00,50,00,65,00,72,00,20,00,53,00,65,00,63,00,6f,00,6e,00,64,00,00,00,52,00,65,00,6c,00,69,00,61,00,62,00,6c,00,65,00,20,00,4d,00,65,00,73,00,73,00,61,00,67,00,69,00,6e,00,67,00,20,00,4d,00,65,00,73,00,73,00,61,00,67,00,65,00,73,00,20,00,44,00,72,00,6f,00,70,00,70,00,65,00,64,00,00,00,52,00,65,00,6c,00,69,00,61,00,62,00,6c,00,65,00,20,00,4d,00,65,00,73,00,73,00,61,00,67,00,69,00,6e,00,67,00,20,00,4d,00,65,00,73,00,73,00,61,00,67,00,65,00,73,00,20,00,44,00,72,00,6f,00,70,00,70,00,65,00,64,00,20,00,50,00,65,00,72,00,20,00,53,00,65,00,63,00,6f,00,6e,00,64,00,00,00,00,00Try doing this:@ECHO OFFSETLOCAL ENABLEDELAYEDEXPANSIONSET LINE=HKLM,"SYSTEM\CurrentControlSet\Services\ServiceModelEndpoint 3.0.0.0\Performance","Counter Names",%%REG_BINARY%%,43,00,61,00,6c,00,6c,00,73,00,00,00,43,00,61,00,6c,00,6c,00,73,00,20,00,50,00,65,00,72,00,20,00,53,00,65,00,63,00,6f,00,6e,00,64,00,00,00,43,00,61,00,6c,00,6c,00,73,00,20,00,4f,00,75,00,74,00,73,00,74,00,61,00,6e,00,64,00,69,00,6e,00,67,00,00,00,43,00,61,00,6c,00,6c,00,73,00,20,00,46,00,61,00,69,00,6c,00,65,00,64,00,00,00,43,00,61,00,6c,00,6c,00,73,00,20,00,46,00,61,00,69,00,6c,00,65,00,64,00,20,00,50,00,65,00,72,00,20,00,53,00,65,00,63,00,6f,00,6e,00,64,00,00,00,43,00,61,00,6c,00,6c,00,73,00,20,00,46,00,61,00,75,00,6c,00,74,00,65,00,64,00,00,00,43,00,61,00,6c,00,6c,00,73,00,20,00,46,00,61,00,75,00,6c,00,74,00,65,00,64,00,20,00,50,00,65,00,72,00,20,00,53,00,65,00,63,00,6f,00,6e,00,64,00,00,00,43,00,61,00,6c,00,6c,00,73,00,20,00,44,00,75,00,72,00,61,00,74,00,69,00,6f,00,6e,00,00,00,43,00,61,00,6c,00,6c,00,73,00,20,00,44,00,75,00,72,00,61,00,74,00,69,00,6f,00,6e,00,20,00,42,00,61,00,73,00,65,00,00,00,54,00,72,00,61,00,6e,00,73,00,61,00,63,00,74,00,69,00,6f,00,6e,00,73,00,20,00,46,00,6c,00,6f,00,77,00,65,00,64,00,00,00,54,00,72,00,61,00,6e,00,73,00,61,00,63,00,74,00,69,00,6f,00,6e,00,73,00,20,00,46,00,6c,00,6f,00,77,00,65,00,64,00,20,00,50,00,65,00,72,00,20,00,53,00,65,00,63,00,6f,00,6e,00,64,00,00,00,53,00,65,00,63,00,75,00,72,00,69,00,74,00,79,00,20,00,56,00,61,00,6c,00,69,00,64,00,61,00,74,00,69,00,6f,00,6e,00,20,00,61,00,6e,00,64,00,20,00,41,00,75,00,74,00,68,00,65,00,6e,00,74,00,69,00,63,00,61,00,74,00,69,00,6f,00,6e,00,20,00,46,00,61,00,69,00,6c,00,75,00,72,00,65,00,73,00,00,00,53,00,65,00,63,00,75,00,72,00,69,00,74,00,79,00,20,00,56,00,61,00,6c,00,69,00,64,00,61,00,74,00,69,00,6f,00,6e,00,20,00,61,00,6e,00,64,00,20,00,41,00,75,00,74,00,68,00,65,00,6e,00,74,00,69,00,63,00,61,00,74,00,69,00,6f,00,6e,00,20,00,46,00,61,00,69,00,6c,00,75,00,72,00,65,00,73,00,20,00,50,00,65,00,72,00,20,00,53,00,65,00,63,00,6f,00,6e,00,64,00,00,00,53,00,65,00,63,00,75,00,72,00,69,00,74,00,79,00,20,00,43,00,61,00,6c,00,6c,00,73,00,20,00,4e,00,6f,00,74,00,20,00,41,00,75,00,74,00,68,00,6f,00,72,00,69,00,7a,00,65,00,64,00,00,00,53,00,65,00,63,00,75,00,72,00,69,00,74,00,79,00,20,00,43,00,61,00,6c,00,6c,00,73,00,20,00,4e,00,6f,00,74,00,20,00,41,00,75,00,74,00,68,00,6f,00,72,00,69,00,7a,00,65,00,64,00,20,00,50,00,65,00,72,00,20,00,53,00,65,00,63,00,6f,00,6e,00,64,00,00,00,52,00,65,00,6c,00,69,00,61,00,62,00,6c,00,65,00,20,00,4d,00,65,00,73,00,73,00,61,00,67,00,69,00,6e,00,67,00,20,00,53,00,65,00,73,00,73,00,69,00,6f,00,6e,00,73,00,20,00,46,00,61,00,75,00,6c,00,74,00,65,00,64,00,00,00,52,00,65,00,6c,00,69,00,61,00,62,00,6c,00,65,00,20,00,4d,00,65,00,73,00,73,00,61,00,67,00,69,00,6e,00,67,00,20,00,53,00,65,00,73,00,73,00,69,00,6f,00,6e,00,73,00,20,00,46,00,61,00,75,00,6c,00,74,00,65,00,64,00,20,00,50,00,65,00,72,00,20,00,53,00,65,00,63,00,6f,00,6e,00,64,00,00,00,52,00,65,00,6c,00,69,00,61,00,62,00,6c,00,65,00,20,00,4d,00,65,00,73,00,73,00,61,00,67,00,69,00,6e,00,67,00,20,00,4d,00,65,00,73,00,73,00,61,00,67,00,65,00,73,00,20,00,44,00,72,00,6f,00,70,00,70,00,65,00,64,00,00,00,52,00,65,00,6c,00,69,00,61,00,62,00,6c,00,65,00,20,00,4d,00,65,00,73,00,73,00,61,00,67,00,69,00,6e,00,67,00,20,00,4d,00,65,00,73,00,73,00,61,00,67,00,65,00,73,00,20,00,44,00,72,00,6f,00,70,00,70,00,65,00,64,00,20,00,50,00,65,00,72,00,20,00,53,00,65,00,63,00,6f,00,6e,00,64,00,00,00,00,00SET LINE=!LINE:%%REG_BINARY%%=0x00000001!ECHO %LINE%The above script won't work in Win2k with its original CMD.EXE. Link to comment Share on other sites More sharing options...
Molecule Posted October 11, 2012 Share Posted October 11, 2012 hmmm ... pathnames ... jaclaz has found a new kind of stegenography (or dirigonography something like that)?echelon will spend all its battery juice trying to translate a hello world file, meanwhile the secret key is in the pathnamespeaking of paths ... there is a larger project(?) happening here which is REALLY nice ... it's inchoate and still undefined at the moment ... a rising event still in the brewing phasetomasz86+BWC,WB,+,+ are moving the powers and driver availability of XP (by adeeming the bubblegum) up into the higher domains of dignity and maturity (and sweetness like wine) of 2000.there is also a parallel effort to strip away the infantile insults and commerical bubblegum from XP, thus renewing driver availabilities and raising powers to the higher dignity of 2000.not sure one path will be easier or better than another ... they both merge into a MOST worthwhile result ... Link to comment Share on other sites More sharing options...
jaclaz Posted October 11, 2012 Share Posted October 11, 2012 Try doing this:@ECHO OFFSETLOCAL ENABLEDELAYEDEXPANSIONSET LINE=HKLM,"SYSTEM\CurrentControlSet\Services\ServiceModelEndpoint 3.0.0.0\Performance","Counter Names",%%REG_BINARY%%,43,00,61,00,6c,00,6c,00,73,00,00,00,43,00,61,00,6c,00,6c,00,73,00,20,00,50,00,65,00,72,00,20,00,53,00,65,00,63,00,6f,00,6e,00,64,00,00,00,43,00,61,00,6c,00,6c,00,73,00,20,00,4f,00,75,00,74,00,73,00,74,00,61,00,6e,00,64,00,69,00,6e,00,67,00,00,00,43,00,61,00,6c,00,6c,00,73,00,20,00,46,00,61,00,69,00,6c,00,65,00,64,00,00,00,43,00,61,00,6c,00,6c,00,73,00,20,00,46,00,61,00,69,00,6c,00,65,00,64,00,20,00,50,00,65,00,72,00,20,00,53,00,65,00,63,00,6f,00,6e,00,64,00,00,00,43,00,61,00,6c,00,6c,00,73,00,20,00,46,00,61,00,75,00,6c,00,74,00,65,00,64,00,00,00,43,00,61,00,6c,00,6c,00,73,00,20,00,46,00,61,00,75,00,6c,00,74,00,65,00,64,00,20,00,50,00,65,00,72,00,20,00,53,00,65,00,63,00,6f,00,6e,00,64,00,00,00,43,00,61,00,6c,00,6c,00,73,00,20,00,44,00,75,00,72,00,61,00,74,00,69,00,6f,00,6e,00,00,00,43,00,61,00,6c,00,6c,00,73,00,20,00,44,00,75,00,72,00,61,00,74,00,69,00,6f,00,6e,00,20,00,42,00,61,00,73,00,65,00,00,00,54,00,72,00,61,00,6e,00,73,00,61,00,63,00,74,00,69,00,6f,00,6e,00,73,00,20,00,46,00,6c,00,6f,00,77,00,65,00,64,00,00,00,54,00,72,00,61,00,6e,00,73,00,61,00,63,00,74,00,69,00,6f,00,6e,00,73,00,20,00,46,00,6c,00,6f,00,77,00,65,00,64,00,20,00,50,00,65,00,72,00,20,00,53,00,65,00,63,00,6f,00,6e,00,64,00,00,00,53,00,65,00,63,00,75,00,72,00,69,00,74,00,79,00,20,00,56,00,61,00,6c,00,69,00,64,00,61,00,74,00,69,00,6f,00,6e,00,20,00,61,00,6e,00,64,00,20,00,41,00,75,00,74,00,68,00,65,00,6e,00,74,00,69,00,63,00,61,00,74,00,69,00,6f,00,6e,00,20,00,46,00,61,00,69,00,6c,00,75,00,72,00,65,00,73,00,00,00,53,00,65,00,63,00,75,00,72,00,69,00,74,00,79,00,20,00,56,00,61,00,6c,00,69,00,64,00,61,00,74,00,69,00,6f,00,6e,00,20,00,61,00,6e,00,64,00,20,00,41,00,75,00,74,00,68,00,65,00,6e,00,74,00,69,00,63,00,61,00,74,00,69,00,6f,00,6e,00,20,00,46,00,61,00,69,00,6c,00,75,00,72,00,65,00,73,00,20,00,50,00,65,00,72,00,20,00,53,00,65,00,63,00,6f,00,6e,00,64,00,00,00,53,00,65,00,63,00,75,00,72,00,69,00,74,00,79,00,20,00,43,00,61,00,6c,00,6c,00,73,00,20,00,4e,00,6f,00,74,00,20,00,41,00,75,00,74,00,68,00,6f,00,72,00,69,00,7a,00,65,00,64,00,00,00,53,00,65,00,63,00,75,00,72,00,69,00,74,00,79,00,20,00,43,00,61,00,6c,00,6c,00,73,00,20,00,4e,00,6f,00,74,00,20,00,41,00,75,00,74,00,68,00,6f,00,72,00,69,00,7a,00,65,00,64,00,20,00,50,00,65,00,72,00,20,00,53,00,65,00,63,00,6f,00,6e,00,64,00,00,00,52,00,65,00,6c,00,69,00,61,00,62,00,6c,00,65,00,20,00,4d,00,65,00,73,00,73,00,61,00,67,00,69,00,6e,00,67,00,20,00,53,00,65,00,73,00,73,00,69,00,6f,00,6e,00,73,00,20,00,46,00,61,00,75,00,6c,00,74,00,65,00,64,00,00,00,52,00,65,00,6c,00,69,00,61,00,62,00,6c,00,65,00,20,00,4d,00,65,00,73,00,73,00,61,00,67,00,69,00,6e,00,67,00,20,00,53,00,65,00,73,00,73,00,69,00,6f,00,6e,00,73,00,20,00,46,00,61,00,75,00,6c,00,74,00,65,00,64,00,20,00,50,00,65,00,72,00,20,00,53,00,65,00,63,00,6f,00,6e,00,64,00,00,00,52,00,65,00,6c,00,69,00,61,00,62,00,6c,00,65,00,20,00,4d,00,65,00,73,00,73,00,61,00,67,00,69,00,6e,00,67,00,20,00,4d,00,65,00,73,00,73,00,61,00,67,00,65,00,73,00,20,00,44,00,72,00,6f,00,70,00,70,00,65,00,64,00,00,00,52,00,65,00,6c,00,69,00,61,00,62,00,6c,00,65,00,20,00,4d,00,65,00,73,00,73,00,61,00,67,00,69,00,6e,00,67,00,20,00,4d,00,65,00,73,00,73,00,61,00,67,00,65,00,73,00,20,00,44,00,72,00,6f,00,70,00,70,00,65,00,64,00,20,00,50,00,65,00,72,00,20,00,53,00,65,00,63,00,6f,00,6e,00,64,00,00,00,00,00SET LINE=!LINE:%%REG_BINARY%%=0x00000001!ECHO %LINE%The above script won't work in Win2k with its original CMD.EXE.Oww, come off it!I do believe that you managed to find a way to break that limit What I wonder is :HOW OFTEN this happensWHY the good MS guys didn't (as they often do for much serious matters) say "it's by design" Back to your finding:What is the actual GOAL of that snippet (obviously it is not that of ECHOing a long string of comma delimited numbers to the screen)?Are you really sure that you need a XP CMD.EXE (and thus - to be "kosher" - an additional license besides the 2K one) to reach that goal? (or there are workarounds or different methods to achieve it still using the 2K CMD.EXE)?jaclaz Link to comment Share on other sites More sharing options...
tomasz86 Posted October 11, 2012 Author Share Posted October 11, 2012 (edited) The goal is pretty simple. This is just a part of a larger script. Basically speaking there's a file with strings, ex.[strings].inf[Strings]FXAssemblyVersion="4.0.0.0"VSAssemblyVersion="10.0.0.0"URTBuildNum="30319"WPFRegistryKey="Windows Presentation Foundation"WPFStaticVersion="4.0"REG_EXPAND_SZ=0x00020000REG_DWORD=0x00010001REG_QWORD=0x000B0001REG_BINARY=0x00000001REG_MULTI_SZ=0x00010000REG_NONE=0x00020001REG_KEYONLY=0x00000010and there are several other files where these strings are used. I want to replace all of them with their real values.FOR /F "skip=1 tokens=* delims=" %%B IN ([Strings].inf) DO ( FOR /F tokens^=1-2^ delims^=^=^" %%C IN ("%%B") DO ( FOR /F "tokens=* delims=" %%E IN ('DIR/B/S *.inf ^| FINDSTR/IV "Strings"') DO ( FINDSTR/IL "%%%%C%%" "%%E" >NUL IF !ERRORLEVEL! EQU 0 ( FINDSTR/VIL "%%%%C%%" "%%E">"%%E.tmp" FOR /F "tokens=* delims=" %%F IN ('FINDSTR/IL "%%%%C%%" "%%E"') DO ( SET STR=%%F SET STR=!STR:%%%%C%%=%%D! ECHO>>"%%E.tmp" !STR! ) MOVE "%%E.tmp" "%%E" ) ) ))Such long lines are not very common but they do appear sometimes. Edited October 11, 2012 by tomasz86 Link to comment Share on other sites More sharing options...
jaclaz Posted October 11, 2012 Share Posted October 11, 2012 And gsar doesn't work for it, right? jaclaz Link to comment Share on other sites More sharing options...
tomasz86 Posted October 12, 2012 Author Share Posted October 12, 2012 And gsar doesn't work for it, right? 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 Link to comment Share on other sites More sharing options...
jaclaz Posted October 12, 2012 Share Posted October 12, 2012 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 .jaclaz Link to comment Share on other sites More sharing options...
Phenomic Posted October 20, 2012 Share Posted October 20, 2012 And gsar doesn't work for it, right? 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: const HKEY_LOCAL_MACHINE = &H80000002strComputer = "."Set StdOut = WScript.StdOutSet oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ strComputer & "\root\default:StdRegProv")strKeyPath = "_offline_\MountedDevices"r1 = oReg.GetBinaryValue(HKEY_LOCAL_MACHINE,strKeyPath,"\DosDevices\Y:",strValue)r3 = oReg.SetBinaryValue(HKEY_LOCAL_MACHINE,strKeyPath,"\DosDevices\Y:",strValue)For i = lBound(strValue) to uBound(strValue) StdOut.Write Hex(strValue(i)) & " "Next Link to comment Share on other sites More sharing options...
bphlpt Posted October 21, 2012 Share Posted October 21, 2012 @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?Cheers and Regards Link to comment Share on other sites More sharing options...
allen2 Posted October 21, 2012 Share Posted October 21, 2012 Set/GetBinaryValue returns its result in r1/r3 but is setting/getting the content of strValue to/from the registry key. Another example at Ms Scripting Guy. Link to comment Share on other sites More sharing options...
Phenomic Posted October 21, 2012 Share Posted October 21, 2012 Yes, r1/r3 are for error handling, strValue is a pointer to the actual string.It was just an example, snippet only. To make it work you can first run: REG.EXE load "HKLM\_offline_to load any registry file (e.g. \system32\config\system), then at the end: REG.EXE unload "HKLM\_offline_"For testing purposes, I used an off-line hive so I don't screw with my actual registry. Link to comment Share on other sites More sharing options...
tomasz86 Posted March 6, 2013 Author Share Posted March 6, 2013 (edited) And gsar doesn't work for it, right? jaclazI'm trying to use gsar now and I've encountered this problem:gsar: command error, length of search or replace buffer must not exceed 256 charsThis happens when trying to replace strings like this one:%BITS_DESCRIPTION%withBITS_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 Link to comment Share on other sites More sharing options...
jaclaz Posted March 6, 2013 Share Posted March 6, 2013 Well, then do it in a few instances, something *like*: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.infmight do.jaclaz Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now