tomasz86 Posted March 6, 2013 Author Share Posted March 6, 2013 Hmm, OK but then the line will have to be divided automatically. At the moment the script looks like this:[strings].inf[Strings]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."FOR /F "skip=1 delims=" %%A IN ([Strings].inf) DO ( FOR /F tokens^=1-2^ delims^=^=^" %%B IN ("%%A") DO ( FOR /F "delims=" %%D IN ('FINDSTR/ILM "%%%%B%%" INF\*.inf') DO ( gsar.exe -i -o -s"%%%%B%%" -r"%%C" "%%D" >NUL ) )) Link to comment Share on other sites More sharing options...
blackwingcat Posted March 7, 2013 Share Posted March 7, 2013 (edited) Japanese version CMD.exe has a difference between XP and 2000.XPecho %DATE%2013/03/07date /T2013/03/072000echo %DATE%木 2013/03/07date /t2013/03/07 木('木' means Thursday) Are there any differences other ? Edited March 7, 2013 by blackwingcat Link to comment Share on other sites More sharing options...
tomasz86 Posted March 7, 2013 Author Share Posted March 7, 2013 Are there any differences other ?Unfortunately the XP's cmd.exe when run in Windows 2000 seems to have extreme memory leaks Link to comment Share on other sites More sharing options...
jaclaz Posted March 7, 2013 Share Posted March 7, 2013 (edited) Japanese version CMD.exe has a difference between XP and 2000.JFYI, the way the DATE /T and TIME/T behave in different versions of Windows (and in different "regional" versions) is a known "nightmare" , same happens - as an example - for "Canadian English":http://www.robvanderwoude.com/datetiment.phpjaclaz Edited March 7, 2013 by jaclaz Link to comment Share on other sites More sharing options...
allen2 Posted March 7, 2013 Share Posted March 7, 2013 Japanese version CMD.exe has a difference between XP and 2000.JFYI, the way the DATE /T and TIME/T behave in different versions of Windows (and in different "regional" versions) is a known "nightmare" , same happens - as an example - for "Canadian English":http://www.robvanderwoude.com/datetiment.phpjaclazAnd %date% and %time% are localized even in XP. Link to comment Share on other sites More sharing options...
tomasz86 Posted March 8, 2013 Author Share Posted March 8, 2013 That's why I use date.exe from UnxUtils. Link to comment Share on other sites More sharing options...
allen2 Posted March 8, 2013 Share Posted March 8, 2013 I do the same most of the time. Link to comment Share on other sites More sharing options...
jaclaz Posted March 8, 2013 Share Posted March 8, 2013 Well, for the record, there is a "way out" without third party tools, using WMI time classes (on XP, NOT on 2K, which misses a few classes).http://technet.microsoft.com/en-us/library/ee198928.aspxhttp://msdn.microsoft.com/en-us/library/windows/desktop/aa394590(v=vs.85).aspxWhat is available should be:Windows 2000Win32_TimeZoneWin32_SystemTimeZoneWindows XPWin32_TimeZoneWin32_SystemTimeZoneWin32_UTCTimeWin32_CurrentTimeWin32_LocalTimeFor 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 .jaclaz Link to comment Share on other sites More sharing options...
bphlpt Posted March 11, 2013 Share Posted March 11, 2013 AFAIK, here is a way to get the current date and time using batch/CMD script that will return a consistently formatted string in any version of Windows from WinXP through Win8 and 2012, (I believe it should also work in Win2K but I would appreciate someone validating that), where the OS is either 32-bit or 64-bit, in any language, in any locale, even if the date/time separators have been modified by the user.Date::: #############################################################################:: :f_GetDate _TodayDate _Year _Month _DayOfMonth:::: Load the ISO format date for today and local date components into variables.:::: Usage: CALL :f_GetDate _TodayVariable _YearVariable _MonthVariable _DayOfMonthVariable:::: This function should get the correct local system date components copied:: into the arguments, passed by reference, regardless of where in the world:: this is run, independent of "International" settings. The arguments are::::: %1 - Variable to receive the date in ISO format (by ref):: %2 - Variable to receive year, 4 digits (by ref):: %3 - Variable to receive month, 2 digits, 01 to 12 (by ref):: %4 - Variable to receive day of month, 2 digits, 01 to 31 (by ref):::: The date in ISO format is equivalent to: %_Year%-%_Month%-%_DayOfMonth%:::: Dependencies: START, REGEDIT [Utilizes a temp file %TEMP%.\_Temp.reg]:::: Originally writen by Rob van der Woude - http://www.robvanderwoude.com as:: SortDate, Version 3.10 for Windows NT4/2000/XP. Adapted for Windows XP with:: help from Kailash Chanduka. Modified slightly by bphlpt.:::: Upon exit, ERRORLEVEL is set to 0.:: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:::f_GetDate _TodayDate _Year _Month _DayOfMonthSETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION:: Export registry settings to temp file, read exported dataSTART "GET iDATE and sDATE" /WAIT REGEDIT /E "%TEMP%.\_Temp.reg" "HKEY_CURRENT_USER\Control Panel\International"FOR /F "tokens=1* delims==" %%G IN ('TYPE "%TEMP%.\_Temp.reg" ^| FIND /I "iDate"') DO (SET _iDate=%%H)FOR /F "tokens=1* delims==" %%G IN ('TYPE "%TEMP%.\_Temp.reg" ^| FIND /I "sDate"') DO (SET _sDate=%%H):: Delete quotes and delete temp file(SET _iDate=%_iDate:"=%)(SET _sDate=%_sDate:"=%)del "%TEMP%.\_Temp.reg" >nul 2>&1:: Parse today's date depending on registry's date format settingsIF %_iDate%==0 (FOR /F "tokens=1-4* delims=%_sDate%" %%G IN ('DATE/T') DO (SET "_Year=%%I"&SET "_Month=%%G"&SET "_Day=%%H")) ELSE (IF %_iDate%==1 (FOR /F "tokens=1-4* delims=%_sDate%" %%G IN ('DATE/T') DO (SET "_Year=%%I"&SET "_Month=%%H"&SET "_Day=%%G")) ELSE (IF %_iDate%==2 (FOR /F "tokens=1-4* delims=%_sDate%" %%G IN ('DATE/T') DO (SET "_Year=%%G"&SET "_Month=%%H"&SET "_Day=%%I")))):: Remove the day of week if applicable(FOR %%G IN (%_Year%) DO (SET "_Year=%%G"))&(FOR %%G IN (%_Month%) DO (SET "_Month=%%G"))&(FOR %%G IN (%_Day%) DO (SET "_Day=%%G")):: Return date and componentsENDLOCAL&(SET "%2=%_Year%"&SET "%3=%_Month%"&SET "%4=%_Day%"&SET "%1=!%2!-!%3!-!%4!")&EXIT /B 0:::: #############################################################################Time::: #############################################################################:: :f_GetTime _Time:::: Load time in a variable, zero padded using ONLY "standard" delimiters (:.):::: Usage: CALL :f_GetTime _Time:::: %_Time% will be set to HH:MM:SS.MSC - NOTE: that MS is now THREE digits:::: Although the default time delimiter, in Windows XP and above is either . or ::: users can change the delimiter to just about any character they like. And you:: know theres always that one guy, the one who writes everything in green ink,:: who will do this! This script always returns HH:MM:SS.MSC, note that MS:: is now 3 digits, no matter which time delimiter has been set in the control:: panel. Based on a discussion at ss64.com, with input from avery_larry and:: bluesxman, and tweaks by bphlpt using examples by Frank Westlake.:::: Dependencies: None:::: Upon exit, ERRORLEVEL is set to 0.:: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:::f_GetTime _TimeSETLOCAL ENABLEEXTENSIONSFOR /F "tokens=1-3 delims=1234567890 " %%G IN ("%TIME%") DO (SET "_Delims=%%G%%H%%I")FOR /F "tokens=1-4 delims=%_Delims% " %%G IN ("%TIME%") DO (SET "_hh=00%%G"&SET "_min=00%%H"&SET "_ss=00%%I"&SET "_ms=00%%J0")ENDLOCAL&(SET %1=%_hh:~-2%:%_min:~-2%:%_ss:~-2%.%_ms:~-3%)&EXIT /B 0:::: #############################################################################Cheers and Regards Link to comment Share on other sites More sharing options...
jaclaz Posted March 11, 2013 Share Posted March 11, 2013 (edited) AFAIK, here is a way to get the current date and time using batch/CMD script that will return a consistently formatted string in any version of Windows from WinXP through Win8 and 2012, (I believe it should also work in Win2K but I would appreciate someone validating that), where the OS is either 32-bit or 64-bit, in any language, in any locale, even if the date/time separators have been modified by the user.They must be VERY different from the ones in the link I gave in post #19 Seriously , what are the changes (improvements) when compared against the "official" SORTDATE/SORTTIME? (which are already "certified" to be working also on NT 4 and 2K) Nesting the IF's with IF/ELSE? jaclaz Edited March 11, 2013 by jaclaz Link to comment Share on other sites More sharing options...
bphlpt Posted March 11, 2013 Share Posted March 11, 2013 (edited) 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 March 11, 2013 by bphlpt Link to comment Share on other sites More sharing options...
jaclaz Posted March 11, 2013 Share Posted March 11, 2013 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 OFFSETLOCALcd.>datefile.$FOR /F "tokens=1,2 delims= " %%A IN ('dir datefile.$ ^| FIND "datefile.$"') DO SET my_date=%%A & SET my_time=%%Bdel 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 OFFSETLOCAL ENABLEEXTENSIONScd.>datefile.$Call :do_date datefile.$GOTO :EOF:do_dateFOR /F "tokens=1,2 delims= " %%A IN ("%~t1") DO SET my_date=%%A & SET my_time=%%Bdel datefile.$set my_jaclaz Link to comment Share on other sites More sharing options...
allen2 Posted March 11, 2013 Share Posted March 11, 2013 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. Link to comment Share on other sites More sharing options...
blackwingcat Posted March 12, 2013 Share Posted March 12, 2013 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] Link to comment Share on other sites More sharing options...
jaclaz Posted March 12, 2013 Share Posted March 12, 2013 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.phpNow, Today and Todaynowjaclaz 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