From 6938aa9201f51c04c8f5fb0ec35c907bd4ef5483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sercan=20Sebet=C3=A7i?= <86542016+sebetci@users.noreply.github.com> Date: Thu, 26 May 2022 00:42:37 +0300 Subject: [PATCH 01/10] add: added naming conventions --- README.md | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 92c23df..1edeaa8 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,24 @@ -batch.scripts -============= +# Batch Script Utils and Examples + +## 1. Naming Conventions + +### 1.1. Functions + +Function names are capitalized and begin with the 'F' character. For example: + +```bash +CALL :FFUNCTION +GOTO :EOF + +:FFUNCTION + ECHO The FFUNCTION function has been executed! + EXIT /B 0 +``` + +### 1.2. Variables + +Variables are written in pascal case and begin with the 'V' character. For example: + +```bash +SET /A VResultData=1 +``` From 8565b5e4deb50496b15043682f1455557f520ccd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sercan=20Sebet=C3=A7i?= <86542016+sebetci@users.noreply.github.com> Date: Thu, 26 May 2022 00:45:01 +0300 Subject: [PATCH 02/10] fix: bugs in find function fixed --- [01].DataStructures/BinaryTree.cmd | 165 +++++++++++++++++++++++++++++ dataStructures/binaryTree.bat | 110 ------------------- 2 files changed, 165 insertions(+), 110 deletions(-) create mode 100644 [01].DataStructures/BinaryTree.cmd delete mode 100644 dataStructures/binaryTree.bat diff --git a/[01].DataStructures/BinaryTree.cmd b/[01].DataStructures/BinaryTree.cmd new file mode 100644 index 0000000..61d1d57 --- /dev/null +++ b/[01].DataStructures/BinaryTree.cmd @@ -0,0 +1,165 @@ +:: =============================================================================================== +:: @file BinaryTree.cmd +:: @brief Binary tree implementation in batch file +:: @usage BinaryTree.cmd +:: @see https://github.com/sebetci/batch.script/[01].DataStructures/BinaryTree.cmd +:: @reference https://en.wikipedia.org/wiki/Binary_tree +:: @reference https://github.com/npocmaka/batch.scripts/tree/master/dataStructures +:: @reference https://www.dostips.com/forum/viewtopic.php?t=7642 +:: @todo The FFIND method does not search after the first level of the tree. +:: @todo The FDELETE method will be developed. +:: =============================================================================================== + +@ECHO OFF +CALL :FMAIN +GOTO :EOF + +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: @function This function inserts new values to the tree and then finds for some values in the tree. +:: @parameter None +:: @return None +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:FMAIN + SETLOCAL ENABLEDELAYEDEXPANSION + + :: This variable must be assigned a value of 1 or 0. + :: If this variable is set to 1, the echo command in its sub-methods will work. + SET /A VDebug=1 + + :: The following commands add new nodes to the tree. + CALL :FINSERT VTreeName 1 + CALL :FINSERT VTreeName 3 + CALL :FINSERT VTreeName 5 + + :: The following commands find for the value 1 in the tree. + :: If the FFIND method finds the value 1, the variable %ERRORLEVEL% has the value 1. + ECHO. + ECHO [VDebug:MAIN] Searching for value 1 + CALL :FFIND VTreeName 1 + ECHO [VDebug:MAIN] Return Value: %ERRORLEVEL% + IF %ERRORLEVEL% EQU 0 (ECHO [VDebug:MAIN] 1 was found in the three.) ELSE (ECHO [VDebug:MAIN] 1 not found in tree.) + + :: The following commands find for the value 1 in the tree. + :: If the FFIND method does not find the value 8, the variable %ERRORLEVEL% will have the value 0. + ECHO. + ECHO [VDebug:MAIN] Searching for value 8 + CALL :FFIND VTreeName 8 + ECHO [VDebug:MAIN] Return Value: %ERRORLEVEL% + IF %ERRORLEVEL% EQU 0 (ECHO [VDebug:MAIN] 8 was found in the three.) ELSE (ECHO [VDebug:MAIN] 8 not found in tree.) + + :: The tree content is printed to the console. + CALL :FPRINT VTreeName + + :: This method content will be developed. + CALL :FDELETE VTreeName + EXIT /B 0 + +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: @function This function searches the Value value in the VTreeName tree. It returns 0 if the +:: searched value is found in the tree. +:: @parameter VTreeName This parameter is the name of the node. +:: @parameter VValue This parameter is the value of the node. +:: @return Returns 0 if value is found in the tree. +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:FFIND VTreeName VValue + SETLOCAL ENABLEDELAYEDEXPANSION + SET /A VValue=%~2 + + IF %VDebug% EQU 1 ECHO [VDebug:FIND] Value-1: %VValue% + IF %VDebug% EQU 1 ECHO [VDebug:FIND] Value-2: %2 + IF %VDebug% EQU 1 ECHO [VDebug:FIND] Tree Name: %1 + + IF %VTreeName% EQU %2 ( + ENDLOCAL & ( + EXIT /B 0 + ) + ) + + IF %VValue% GTR %1 ( + IF DEFINED %1R ( + ENDLOCAL & ( + CALL :FFIND %1R %VValue% + ) + ) ELSE ( + ENDLOCAL & ( + EXIT /B 1 + ) + ) + ) + + IF %VValue% LSS %1 ( + IF DEFINED %1L ( + ENDLOCAL & ( + CALL :FFIND %1L %VValue% + ) + ) ELSE ( + ENDLOCAL & ( + EXIT /B 1 + ) + ) + ) + + EXIT /B + +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: @function This function adds a new node to the tree. +:: @parameter VTreeName This parameter is the name of the node. +:: @parameter VValue This parameter is the value of the node. +:: @return None +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:FINSERT VTreeName VValue + SETLOCAL + SET /A VValue=%~2 + + IF NOT DEFINED %~1 ( + ENDLOCAL & ( + SET "%~1=%VValue%" + EXIT /B 0 + ) + ) + + IF %VValue% GEQ %~1R ( + IF NOT DEFINED %~1R ( + ENDLOCAL & ( + SET %~1R=%VValue% + EXIT /B 0 + ) + ) ELSE ( + ENDLOCAL & ( + CALL ::FINSERT %~1R %VValue% + ) + ) + ) + + IF %VValue% LSS %~1L ( + IF NOT DEFINED %~1L ( + ENDLOCAL & ( + SET %~1L=%VValue% + EXIT /B 0 + ) + ) ELSE ( + ENDLOCAL & ( + CALL ::FINSERT %~1R %VValue% + ) + ) + ) + EXIT /B 0 + +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: @function This function prints the names and values of the node nodes in the tree. +:: @parameter VTreeName This parameter is the name of the node. +:: @return None +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:FPRINT VTreeName + ECHO. + SET VTreeName + EXIT /B 0 + +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: @function This function deletes all nodes in a tree. +:: @parameter VTreeName This parameter is the name of the node. +:: @return None +:: @todo Investigate the feasibility of this method. +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:FDELETE VTreeName + EXIT /B 0 \ No newline at end of file diff --git a/dataStructures/binaryTree.bat b/dataStructures/binaryTree.bat deleted file mode 100644 index 351a563..0000000 --- a/dataStructures/binaryTree.bat +++ /dev/null @@ -1,110 +0,0 @@ -@echo off -setlocal enableDelayedExpansion - -:: Binary tree implementation with pure batch -:: only insert and find methods are implmented so far -:: -:: it uses the binary tree name as the variable that holds -:: the root element and adds revursively to namer right elements -:: and namel the left elements. - -:::--- some tests ----- -call ::insert test_tree6 1 -call ::insert test_tree6 5 -call ::insert test_tree6 8 -call ::insert test_tree6 9999 - -color -echo searching for value 8 -call ::find test_tree6 8 -echo %errorlevel% - if 0 element is found -echo searching for value 123 -call ::find test_tree6 123 -echo %errorlevel% - if 1 element is not found -set test_tree6 -:::::::::::::::::::::::::::::: - -exit /b 0 - - -:find three_name value -setlocal enableDelayedExpansion -set /a value=%~2 -set node=%1 - -if %value% equ !%1! ( - endlocal & ( - echo %1 - exit /b 0 - ) -) - - -if %value% GTR !%1! ( - if defined %1r ( - endlocal & ( - call ::find %1r %value% - ) - ) else ( - endlocal & exit /b 1 - ) -) - -if %value% LSS !%1! ( - if defined %1l ( - endlocal & ( - call ::find %1l %value% - ) - ) else ( - endlocal & exit /b 1 - ) -) - - -exit /b - - - -:insert three_name value -setlocal -::set "three_name=%~1" -set /a value=%~2 - -if not defined %~1 ( - endlocal & ( - set "%~1=%value%" - exit /b 0 - ) -) - -if %value% GEQ %~1r ( - if not defined %~1r ( - endlocal & ( - set %~1r=%value% - exit /b 0 - ) - ) else ( - endlocal & ( - call ::insert %~1r %value% - rem exit /b 0 - ) - ) -) - -if %value% LSS %~1l ( - if not defined %~1l ( - endlocal & ( - set %~1l=%value% - exit /b 0 - ) - ) else ( - endlocal & ( - call ::insert %~1r %value% - rem exit /b 0 - ) - ) -) - -exit /b 0 - -:delete From 875d08c41bb678d6365f598a1bb34903b85f5d8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sercan=20Sebet=C3=A7i?= <86542016+sebetci@users.noreply.github.com> Date: Thu, 26 May 2022 01:27:14 +0300 Subject: [PATCH 03/10] add: added new parameters to follow in debug mode --- .../{BinaryTree.cmd => BinaryTree.bat} | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) rename [01].DataStructures/{BinaryTree.cmd => BinaryTree.bat} (90%) diff --git a/[01].DataStructures/BinaryTree.cmd b/[01].DataStructures/BinaryTree.bat similarity index 90% rename from [01].DataStructures/BinaryTree.cmd rename to [01].DataStructures/BinaryTree.bat index 61d1d57..ffb1c12 100644 --- a/[01].DataStructures/BinaryTree.cmd +++ b/[01].DataStructures/BinaryTree.bat @@ -34,10 +34,10 @@ GOTO :EOF :: The following commands find for the value 1 in the tree. :: If the FFIND method finds the value 1, the variable %ERRORLEVEL% has the value 1. ECHO. - ECHO [VDebug:MAIN] Searching for value 1 - CALL :FFIND VTreeName 1 + ECHO [VDebug:MAIN] Searching for value 5 + CALL :FFIND VTreeName 5 ECHO [VDebug:MAIN] Return Value: %ERRORLEVEL% - IF %ERRORLEVEL% EQU 0 (ECHO [VDebug:MAIN] 1 was found in the three.) ELSE (ECHO [VDebug:MAIN] 1 not found in tree.) + IF %ERRORLEVEL% EQU 0 (ECHO [VDebug:MAIN] 5 was found in the three.) ELSE (ECHO [VDebug:MAIN] 5 not found in tree.) :: The following commands find for the value 1 in the tree. :: If the FFIND method does not find the value 8, the variable %ERRORLEVEL% will have the value 0. @@ -62,12 +62,13 @@ GOTO :EOF :: @return Returns 0 if value is found in the tree. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :FFIND VTreeName VValue - SETLOCAL ENABLEDELAYEDEXPANSION + :: SETLOCAL ENABLEDELAYEDEXPANSION SET /A VValue=%~2 - IF %VDebug% EQU 1 ECHO [VDebug:FIND] Value-1: %VValue% - IF %VDebug% EQU 1 ECHO [VDebug:FIND] Value-2: %2 - IF %VDebug% EQU 1 ECHO [VDebug:FIND] Tree Name: %1 + IF %VDebug% EQU 1 ECHO [VDebug:FIND] Content-1: %VTreeName% + IF %VDebug% EQU 1 ECHO [VDebug:FIND] Content-2: %VValue% + IF %VDebug% EQU 1 ECHO [VDebug:FIND] Param-1: %1 + IF %VDebug% EQU 1 ECHO [VDebug:FIND] Param-2: %2 IF %VTreeName% EQU %2 ( ENDLOCAL & ( @@ -126,7 +127,7 @@ GOTO :EOF ) ) ELSE ( ENDLOCAL & ( - CALL ::FINSERT %~1R %VValue% + CALL :FINSERT %~1R %VValue% ) ) ) @@ -139,7 +140,7 @@ GOTO :EOF ) ) ELSE ( ENDLOCAL & ( - CALL ::FINSERT %~1R %VValue% + CALL :FINSERT %~1R %VValue% ) ) ) From b14a4bc40c426eb7ad40729e4a82432a26c065dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sercan=20Sebet=C3=A7i?= <86542016+sebetci@users.noreply.github.com> Date: Thu, 26 May 2022 01:35:10 +0300 Subject: [PATCH 04/10] edit: only the first node is searched. --- [01].DataStructures/BinaryTree.bat | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/[01].DataStructures/BinaryTree.bat b/[01].DataStructures/BinaryTree.bat index ffb1c12..9d27961 100644 --- a/[01].DataStructures/BinaryTree.bat +++ b/[01].DataStructures/BinaryTree.bat @@ -34,10 +34,10 @@ GOTO :EOF :: The following commands find for the value 1 in the tree. :: If the FFIND method finds the value 1, the variable %ERRORLEVEL% has the value 1. ECHO. - ECHO [VDebug:MAIN] Searching for value 5 - CALL :FFIND VTreeName 5 + ECHO [VDebug:MAIN] Searching for value 1 + CALL :FFIND VTreeName 1 ECHO [VDebug:MAIN] Return Value: %ERRORLEVEL% - IF %ERRORLEVEL% EQU 0 (ECHO [VDebug:MAIN] 5 was found in the three.) ELSE (ECHO [VDebug:MAIN] 5 not found in tree.) + IF %ERRORLEVEL% EQU 0 (ECHO [VDebug:MAIN] 1 was found in the three.) ELSE (ECHO [VDebug:MAIN] 1 not found in tree.) :: The following commands find for the value 1 in the tree. :: If the FFIND method does not find the value 8, the variable %ERRORLEVEL% will have the value 0. From 9b02cd51bad1cbb8389411cffb6edfd0d023e526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sercan=20Sebet=C3=A7i?= <86542016+sebetci@users.noreply.github.com> Date: Thu, 26 May 2022 02:00:35 +0300 Subject: [PATCH 05/10] edit: this script was not working on Windows 10 --- DateAndTime/DateParts.bat | 24 ------------------------ [02].DateAndTime/DateParts.bat | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 24 deletions(-) delete mode 100644 DateAndTime/DateParts.bat create mode 100644 [02].DateAndTime/DateParts.bat diff --git a/DateAndTime/DateParts.bat b/DateAndTime/DateParts.bat deleted file mode 100644 index 7709d32..0000000 --- a/DateAndTime/DateParts.bat +++ /dev/null @@ -1,24 +0,0 @@ -@echo off -rem gets Date Parts -rem by Vasil "npocmaka" Arnaudov -rem 21.01.15 - improvement was proposed by Ildar Shaimordanov - a.k.a siberia-man -rem - to use empty folder to increase performance -for /f "skip=10 tokens=2,3,4,5,6,7,8 delims=: " %%D in (' - robocopy /l * "%windir%\System32\wbem\MOF\bad" "%windir%\System32\wbem\MOF\bad" /ns /nc /ndl /nfl /np /njh /XF * /XD * -') do ( - set "dow=%%D" - set "month=%%E" - set "day=%%F" - set "HH=%%G" - set "MM=%%H" - set "SS=%%I" - set "year=%%J" -) - -echo Day of the week: %dow% -echo Day of the month : %day% -echo Month : %month% -echo hour : %HH% -echo minutes : %MM% -echo seconds : %SS% -echo year : %year% diff --git a/[02].DateAndTime/DateParts.bat b/[02].DateAndTime/DateParts.bat new file mode 100644 index 0000000..c374429 --- /dev/null +++ b/[02].DateAndTime/DateParts.bat @@ -0,0 +1,23 @@ +:: =============================================================================================== +:: @file DateParts.bat +:: @brief Gets date parts +:: @usage DateParts.bat +:: @see https://github.com/sebetci/batch.script/[02].DateAndTime/DateParts.bat +:: @reference https://stackoverflow.com/a/28250863/15032688 +:: @reference https://www.dostips.com/forum/viewtopic.php?f=3&t=4555 +:: @todo +:: =============================================================================================== + +@ECHO OFF +PUSHD "%TEMP%" +MAKECAB /D RPTFILENAME=~.RPT /D INFFILENAME=~.INF /F NUL >NUL + +FOR /F "TOKENS=3-7" %%A IN ('FIND /I "MAKECAB"^<~.RPT') DO ( + SET "VWeekDay=%%A" + SET "VCurrentDate=%%E-%%B-%%C" + SET "VCurrentTime=%%D" +) +DEL ~.* +POPD +ECHO %VWeekDay% %VCurrentDate% %VCurrentTime% +GOTO :EOF \ No newline at end of file From 2022d7dd2a5e2f8cf9fee6b078e3f9d72a5923e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sercan=20Sebet=C3=A7i?= <86542016+sebetci@users.noreply.github.com> Date: Thu, 26 May 2022 02:13:37 +0300 Subject: [PATCH 06/10] edit: time output displayed in ISO 8061 Date and Time Format --- DateAndTime/getTime.bat | 25 ------------------------- [02].DateAndTime/GetTime.bat | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 25 deletions(-) delete mode 100644 DateAndTime/getTime.bat create mode 100644 [02].DateAndTime/GetTime.bat diff --git a/DateAndTime/getTime.bat b/DateAndTime/getTime.bat deleted file mode 100644 index ee91982..0000000 --- a/DateAndTime/getTime.bat +++ /dev/null @@ -1,25 +0,0 @@ -@echo off - -:: gets time using typePerf command -:: with put some effort to be made fast and maximum compatible - -setlocal -::check if windows is XP and use XP valid counter for UDP performance -if defined USERDOMAIN_roamingprofile (set "v=v4") else (set "v=") -set "mon=" -for /f "skip=2 delims=," %%# in ('typeperf "\UDP%v%\*" -si 0 -sc 1') do ( - if not defined mon ( - for /f "tokens=1-7 delims=.:/ " %%a in (%%#) do ( - set mon=%%a - set date=%%b - set year=%%c - set hour=%%d - set minute=%%e - set sec=%%f - set ms=%%g - ) - ) -) -echo %year%.%mon%.%date% -echo %hour%:%minute%:%sec%.%ms% -endlocal diff --git a/[02].DateAndTime/GetTime.bat b/[02].DateAndTime/GetTime.bat new file mode 100644 index 0000000..fc83fd4 --- /dev/null +++ b/[02].DateAndTime/GetTime.bat @@ -0,0 +1,35 @@ +:: =============================================================================================== +:: @file GetTime.bat +:: @brief Gets time using typeperf command with put some effort to be made fast and +:: maximum compatible. +:: @usage GetTime.bat +:: @see https://github.com/sebetci/batch.script/[02].DateAndTime/GetTime.bat +:: @reference https://www.progress.com/blogs/understanding-iso-8601-date-and-time-format +:: @reference https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/typeperf +:: @todo +:: =============================================================================================== + +@ECHO OFF +SETLOCAL + :: Check if Windows is XP and use XP valid counter for UDP performance + :: In Windows 10 the variable "USERDOMAIN_ROAMINGPROFILE" returns the device name. + IF DEFINED USERDOMAIN_ROAMINGPROFILE (SET "V=V4" & ECHO Device Name: %USERDOMAIN_ROAMINGPROFILE%) ELSE (SET "V=") + + :: The "typeperf" command writes performance counter data to the command window or to a supported log file format. + FOR /F "SKIP=2 DELIMS=," %%# IN ('TYPEPERF "\UDP%V%\*" -SI 0 -SC 1') DO ( + IF NOT DEFINED VMonth ( + FOR /F "TOKENS=1-7 DELIMS=.:/ " %%A IN (%%#) DO ( + SET VMonth=%%A + SET VDate=%%B + SET VYear=%%C + SET VHour=%%D + SET VMinute=%%E + SET VSecond=%%F + SET VMillisecond=%%G + ) + ) + ) + + :: ISO 8601 Date and Time Format + ECHO %VYear%-%VMonth%-%VDate% %VHour%:%VMinute%:%VSecond%.%VMillisecond% +ENDLOCAL \ No newline at end of file From 79927bafea20fa078d4cb1b8db39b33df3a61abb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sercan=20Sebet=C3=A7i?= <86542016+sebetci@users.noreply.github.com> Date: Thu, 26 May 2022 02:25:06 +0300 Subject: [PATCH 07/10] edit: the code is documented. --- DateAndTime/sleeptp.bat | 18 --------------- [02].DateAndTime/SleepEmulator.bat | 36 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 18 deletions(-) delete mode 100644 DateAndTime/sleeptp.bat create mode 100644 [02].DateAndTime/SleepEmulator.bat diff --git a/DateAndTime/sleeptp.bat b/DateAndTime/sleeptp.bat deleted file mode 100644 index 6a2405e..0000000 --- a/DateAndTime/sleeptp.bat +++ /dev/null @@ -1,18 +0,0 @@ -@echo off -:: yet another sleep emulator working on everything from NT and above -if "%~1"=="" goto :help -ECHO.%*| FINDSTR /R /X /C:"[0-9][0-9]*" >NUL 2>NUL || goto :help -IF %~1 LSS 0 goto :help - -typeperf "\System\Processor Queue Length" -si %~1 -sc 1 >nul - -goto :eof -:help -echo. -echo %~n0 -echo Sleep emulator -echo Wait for a specified number of seconds. -echo. -echo Usage: CALL %~n0 seconds -echo. -echo seconds - seconds to wait diff --git a/[02].DateAndTime/SleepEmulator.bat b/[02].DateAndTime/SleepEmulator.bat new file mode 100644 index 0000000..345f1ce --- /dev/null +++ b/[02].DateAndTime/SleepEmulator.bat @@ -0,0 +1,36 @@ +:: =============================================================================================== +:: @file SleepEmulator.bat +:: @brief Yet another sleep emulator working on everything from NT and above +:: @syntax SleepEmulator.bat +:: @usage SleepEmulator.bat 10 +:: @description The above call provides a 10 second delay. +:: @see https://github.com/sebetci/batch.script/[02].DateAndTime/SleepEmulator.bat +:: @reference https://www.robvanderwoude.com/wait.php +:: @todo +:: =============================================================================================== + +@ECHO OFF + +:: If there isn't first parameter, exit the script. +IF "%~1"=="" GOTO :HELP + +:: If the first parameter isn't a number, exit the script. +ECHO.%*| FINDSTR /R /X /C:"[0-9][0-9]*" >NUL 2>NUL || GOTO :HELP + +:: If the first parameter is less than 0, exit the script. +IF %~1 LSS 0 GOTO :HELP + +:: The "typeperf" command writes performance counter data to the command window or to a supported log file format. +TYPEPERF "\SYSTEM\PROCESSOR QUEUE LENGTH" -SI %~1 -SC 1 >NUL +GOTO :EOF + +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: @function This function prints the help menu on the screen. +:: @parameter None +:: @return None +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:HELP + ECHO Program Name: %~N0 + ECHO Description: Wait for a specifier number of seconds + ECHO Syntax: SleepEmulator.bat ^ + EXIT /B 0 \ No newline at end of file From 40d163dbeae95ffd645d963756411adb6b8079a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sercan=20Sebet=C3=A7i?= <86542016+sebetci@users.noreply.github.com> Date: Thu, 26 May 2022 02:42:22 +0300 Subject: [PATCH 08/10] edit: the code is documented. --- DateAndTime/W32DOW.bat | 31 ---------------------- [02].DateAndTime/W32DOW.bat | 51 +++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 31 deletions(-) delete mode 100644 DateAndTime/W32DOW.bat create mode 100644 [02].DateAndTime/W32DOW.bat diff --git a/DateAndTime/W32DOW.bat b/DateAndTime/W32DOW.bat deleted file mode 100644 index 20498b2..0000000 --- a/DateAndTime/W32DOW.bat +++ /dev/null @@ -1,31 +0,0 @@ -@echo off -setlocal -rem :: prints the day of the week -rem :: works on Vista and above -rem :: by Vasil "npocmaka" Arnaudov - - rem :: getting ansi date ( days passed from 1st jan 1601 ) , timer server hour and current hour - FOR /F "skip=16 tokens=4,5 delims=:( " %%D in ('w32tm /stripchart /computer:localhost /samples:1 /period:1 /dataonly /packetinfo') do ( - set "ANSI_DATE=%%D" - set "TIMESERVER_HOURS=%%E" - goto :end_for ) - :end_for - set "LOCAL_HOURS=%TIME:~0,2%" - if "%TIMESERVER_HOURS:~0,1%0" EQU "00" set TIMESERVER_HOURS=%TIMESERVER_HOURS:~1,1% - if "%LOCAL_HOURS:~0,1%0" EQU "00" set LOCAL_HOURS=%LOCAL_HOURS:~1,1% - set /a OFFSET=TIMESERVER_HOURS-LOCAL_HOURS - - rem :: day of the week will be the modulus of 7 of local ansi date +1 - rem :: we need need +1 because Monday will be calculated as 0 - rem :: 1st jan 1601 was Monday - - rem :: if abs(offset)>12 we are in different days with the time server - - IF %OFFSET%0 GTR 120 set /a DOW=(ANSI_DATE+1)%%7+1 - IF %OFFSET%0 LSS -120 set /a DOW=(ANSI_DATE-1)%%7+1 - IF %OFFSET%0 LEQ 120 IF %OFFSET%0 GEQ -120 set /a DOW=ANSI_DATE%%7+1 - - - echo Day of the week: %DOW% - exit /b 2147483648 -endlocal diff --git a/[02].DateAndTime/W32DOW.bat b/[02].DateAndTime/W32DOW.bat new file mode 100644 index 0000000..3597467 --- /dev/null +++ b/[02].DateAndTime/W32DOW.bat @@ -0,0 +1,51 @@ +:: =============================================================================================== +:: @file W32DOW.bat +:: @brief Prints the day of the week +:: @syntax W32DOW.bat +:: @usage +:: @description +:: @see https://github.com/sebetci/batch.script/[02].DateAndTime/W32DOW.bat +:: @reference https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/ff799054(v=ws.11) +:: @reference https://en.wikipedia.org/wiki/W32tm +:: @todo +:: =============================================================================================== + +@ECHO OFF +SETLOCAL + :: Getting ANSI Date (Days passed from 1st Jan 1601), Timer Server Hour and Current Hour + :: In computing, W32TM is a command-line tool of Microsoft Windows operating systems used + :: to diagnose problems occurring with time setting or to troubleshoot any problems that might + :: occur during or after the configuration of the Windows Time service. + FOR /F "SKIP=16 TOKENS=4,5 DELIMS=:(" %%D IN ('W32TM /STRIPCHART /COMPUTER:LOCALHOST /SAMPLES:1 /PERIOD:1 /DATAONLY /PACKETINFO') DO ( + SET "VANSIDate=%%D" + ECHO [DEBUG:MAIN] ANSI Date: %VANSIDate% + + SET "VTimeServerHours=%%E" + ECHO [DEBUG:MAIN] Time Server Hours: %VTimeServerHours% + + GOTO :FENDFOR + ) + +:FENDFOR + ECHO [DEBUG:ENDFOR] Time: %TIME% + SET "VLocalHours=%TIME:~0,2%" + + IF "%VTimeServerHours:~0,1%0" EQU "00" SET VTimeServerHours=%VTimeServerHours:~1,1% + ECHO [DEBUG:ENDFOR] Time Server Hours: %VTimeServerHours% + + IF "%VLocalHours:~0,1%0" EQU "00" SET VLocalHours=%VLocalHours:~1,1% + ECHO [DEBUG:ENDFOR] Local Hours: %VLocalHours% + + SET /A VOffset=VTimeServerHours-VLocalHours + ECHO [DEBUG:ENDFOR] Offset: %VOffset% + + :: Day of the week will be the modulus of 7 of local ANSI date +1. + :: We need +1 because monday will be calculated as 0. 1st Jan 1601 was monday. + :: If ABS(VOffset)>12 we are in different days with the time server. + IF %VOffset%0 GTR 120 SET /A DOW=(VANSIDate+1)%%7+1 + IF %VOffset%0 LSS -120 SET /A DOW=(VANSIDate-1)%%7+1 + IF %VOffset%0 LEQ 120 IF %VOffset%0 GEQ -120 SET /A DOW=VANSIDate%%7+1 + + ECHO DAY OF THE WEEK: %DOW% + EXIT /B 2147483648 +ENDLOCAL \ No newline at end of file From b9cf352ab28073138b998a4cbfcbe767de7a5948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sercan=20Sebet=C3=A7i?= <86542016+sebetci@users.noreply.github.com> Date: Thu, 26 May 2022 02:57:50 +0300 Subject: [PATCH 09/10] edit: the code is documented --- DateAndTime/W32tmSleep.bat | 24 ----------------- [02].DateAndTime/SleepEmulator.bat | 2 +- [02].DateAndTime/W32DOW.bat | 2 -- [02].DateAndTime/W32TMSleep.bat | 43 ++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 27 deletions(-) delete mode 100644 DateAndTime/W32tmSleep.bat create mode 100644 [02].DateAndTime/W32TMSleep.bat diff --git a/DateAndTime/W32tmSleep.bat b/DateAndTime/W32tmSleep.bat deleted file mode 100644 index 2933d57..0000000 --- a/DateAndTime/W32tmSleep.bat +++ /dev/null @@ -1,24 +0,0 @@ -@echo off -:: yet another sleep emulator working on everything from NT and above -if "%~1"=="" goto :help -ECHO.%*| FINDSTR /R /X /C:"[0-9][0-9]*" >NUL || goto :help -IF %~1 LSS 0 goto :help - -setLocal - set /a adj=%~1/2+1 - w32tm /stripchart /computer:localhost /period:1 /dataonly /samples:%adj% >nul 2>&1 -endLocal - -goto :eof -:help -echo. -echo %~n0 -echo Sleep emulator -echo Wait for a specified number of seconds. -echo. -echo Usage: CALL %~n0 seconds -echo. -echo seconds - seconds to wait -echo. -echo. -echo by Vasil "npocmaka" Arnaudov diff --git a/[02].DateAndTime/SleepEmulator.bat b/[02].DateAndTime/SleepEmulator.bat index 345f1ce..60ea1bc 100644 --- a/[02].DateAndTime/SleepEmulator.bat +++ b/[02].DateAndTime/SleepEmulator.bat @@ -1,7 +1,7 @@ :: =============================================================================================== :: @file SleepEmulator.bat :: @brief Yet another sleep emulator working on everything from NT and above -:: @syntax SleepEmulator.bat +:: @syntax SleepEmulator.bat :: @usage SleepEmulator.bat 10 :: @description The above call provides a 10 second delay. :: @see https://github.com/sebetci/batch.script/[02].DateAndTime/SleepEmulator.bat diff --git a/[02].DateAndTime/W32DOW.bat b/[02].DateAndTime/W32DOW.bat index 3597467..50669a2 100644 --- a/[02].DateAndTime/W32DOW.bat +++ b/[02].DateAndTime/W32DOW.bat @@ -2,8 +2,6 @@ :: @file W32DOW.bat :: @brief Prints the day of the week :: @syntax W32DOW.bat -:: @usage -:: @description :: @see https://github.com/sebetci/batch.script/[02].DateAndTime/W32DOW.bat :: @reference https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/ff799054(v=ws.11) :: @reference https://en.wikipedia.org/wiki/W32tm diff --git a/[02].DateAndTime/W32TMSleep.bat b/[02].DateAndTime/W32TMSleep.bat new file mode 100644 index 0000000..289d385 --- /dev/null +++ b/[02].DateAndTime/W32TMSleep.bat @@ -0,0 +1,43 @@ +:: =============================================================================================== +:: @file W32TMSleep.bat +:: @brief Yet another sleep emulator working on everything from NT and above +:: @syntax W32TMSleep.bat +:: @usage W32TMSleep.bat 10 +:: @description The above call provides a 10 second delay. +:: @see https://github.com/sebetci/batch.script/[02].DateAndTime/W32TMSleep.bat +:: @reference https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/ff799054(v=ws.11) +:: @reference https://en.wikipedia.org/wiki/W32tm +:: @todo +:: =============================================================================================== + +@ECHO OFF + +:: If there isn't first parameter, exit the script. +IF "%~1"=="" GOTO :HELP + +:: If the first parameter isn't a number, exit the script. +ECHO.%*| FINDSTR /R /X /C:"[0-9][0-9]*" >NUL 2>NUL || GOTO :HELP + +:: If the first parameter is less than 0, exit the script. +IF %~1 LSS 0 GOTO :HELP + +SETLOCAL + SET /A VAdjust=%~1/2+1 + + :: In computing, W32TM is a command-line tool of Microsoft Windows operating systems used + :: to diagnose problems occurring with time setting or to troubleshoot any problems that might + :: occur during or after the configuration of the Windows Time service. + W32TM /STRIPCHART /COMPUTER:LOCALHOST /PERIOD:1 /DATAONLY /SAMPLES:%VAdjust% >NUL 2>&1 +ENDLOCAL +GOTO :EOF + +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: @function This function prints the help menu on the screen. +:: @parameter None +:: @return None +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:HELP + ECHO Program Name: %~N0 + ECHO Description: Wait for a specifier number of seconds + ECHO Syntax: W32TMSleep.bat ^ + EXIT /B 0 \ No newline at end of file From e1d213e3182fbf2c8486506f8c2a7f373bb5408b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sercan=20Sebet=C3=A7i?= <86542016+sebetci@users.noreply.github.com> Date: Thu, 26 May 2022 03:37:19 +0300 Subject: [PATCH 10/10] edit: typo --- [01].DataStructures/BinaryTree.bat | 30 +++++++++++++++--------------- [02].DateAndTime/DateParts.bat | 7 +++++-- [02].DateAndTime/GetTime.bat | 4 ++-- [02].DateAndTime/SleepEmulator.bat | 16 ++++++++-------- [02].DateAndTime/W32DOW.bat | 4 ++-- [02].DateAndTime/W32TMSleep.bat | 16 ++++++++-------- 6 files changed, 40 insertions(+), 37 deletions(-) diff --git a/[01].DataStructures/BinaryTree.bat b/[01].DataStructures/BinaryTree.bat index 9d27961..8b4d837 100644 --- a/[01].DataStructures/BinaryTree.bat +++ b/[01].DataStructures/BinaryTree.bat @@ -1,24 +1,24 @@ -:: =============================================================================================== -:: @file BinaryTree.cmd +:: =========================================================================================================== +:: @file BinaryTree.bat :: @brief Binary tree implementation in batch file -:: @usage BinaryTree.cmd -:: @see https://github.com/sebetci/batch.script/[01].DataStructures/BinaryTree.cmd +:: @usage BinaryTree.bat +:: @see https://github.com/sebetci/batch.script/[01].DataStructures/BinaryTree.bat :: @reference https://en.wikipedia.org/wiki/Binary_tree :: @reference https://github.com/npocmaka/batch.scripts/tree/master/dataStructures :: @reference https://www.dostips.com/forum/viewtopic.php?t=7642 :: @todo The FFIND method does not search after the first level of the tree. :: @todo The FDELETE method will be developed. -:: =============================================================================================== +:: =========================================================================================================== @ECHO OFF CALL :FMAIN GOTO :EOF -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: @function This function inserts new values to the tree and then finds for some values in the tree. :: @parameter None :: @return None -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :FMAIN SETLOCAL ENABLEDELAYEDEXPANSION @@ -54,13 +54,13 @@ GOTO :EOF CALL :FDELETE VTreeName EXIT /B 0 -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: @function This function searches the Value value in the VTreeName tree. It returns 0 if the :: searched value is found in the tree. :: @parameter VTreeName This parameter is the name of the node. :: @parameter VValue This parameter is the value of the node. :: @return Returns 0 if value is found in the tree. -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :FFIND VTreeName VValue :: SETLOCAL ENABLEDELAYEDEXPANSION SET /A VValue=%~2 @@ -102,12 +102,12 @@ GOTO :EOF EXIT /B -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: @function This function adds a new node to the tree. :: @parameter VTreeName This parameter is the name of the node. :: @parameter VValue This parameter is the value of the node. :: @return None -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :FINSERT VTreeName VValue SETLOCAL SET /A VValue=%~2 @@ -146,21 +146,21 @@ GOTO :EOF ) EXIT /B 0 -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: @function This function prints the names and values of the node nodes in the tree. :: @parameter VTreeName This parameter is the name of the node. :: @return None -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :FPRINT VTreeName ECHO. SET VTreeName EXIT /B 0 -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: @function This function deletes all nodes in a tree. :: @parameter VTreeName This parameter is the name of the node. :: @return None :: @todo Investigate the feasibility of this method. -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :FDELETE VTreeName EXIT /B 0 \ No newline at end of file diff --git a/[02].DateAndTime/DateParts.bat b/[02].DateAndTime/DateParts.bat index c374429..18c83e8 100644 --- a/[02].DateAndTime/DateParts.bat +++ b/[02].DateAndTime/DateParts.bat @@ -1,15 +1,17 @@ -:: =============================================================================================== +:: =========================================================================================================== :: @file DateParts.bat :: @brief Gets date parts :: @usage DateParts.bat :: @see https://github.com/sebetci/batch.script/[02].DateAndTime/DateParts.bat :: @reference https://stackoverflow.com/a/28250863/15032688 :: @reference https://www.dostips.com/forum/viewtopic.php?f=3&t=4555 +:: @reference https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/makecab :: @todo -:: =============================================================================================== +:: =========================================================================================================== @ECHO OFF PUSHD "%TEMP%" + MAKECAB /D RPTFILENAME=~.RPT /D INFFILENAME=~.INF /F NUL >NUL FOR /F "TOKENS=3-7" %%A IN ('FIND /I "MAKECAB"^<~.RPT') DO ( @@ -17,6 +19,7 @@ FOR /F "TOKENS=3-7" %%A IN ('FIND /I "MAKECAB"^<~.RPT') DO ( SET "VCurrentDate=%%E-%%B-%%C" SET "VCurrentTime=%%D" ) + DEL ~.* POPD ECHO %VWeekDay% %VCurrentDate% %VCurrentTime% diff --git a/[02].DateAndTime/GetTime.bat b/[02].DateAndTime/GetTime.bat index fc83fd4..8f3fbfe 100644 --- a/[02].DateAndTime/GetTime.bat +++ b/[02].DateAndTime/GetTime.bat @@ -1,4 +1,4 @@ -:: =============================================================================================== +:: =========================================================================================================== :: @file GetTime.bat :: @brief Gets time using typeperf command with put some effort to be made fast and :: maximum compatible. @@ -7,7 +7,7 @@ :: @reference https://www.progress.com/blogs/understanding-iso-8601-date-and-time-format :: @reference https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/typeperf :: @todo -:: =============================================================================================== +:: =========================================================================================================== @ECHO OFF SETLOCAL diff --git a/[02].DateAndTime/SleepEmulator.bat b/[02].DateAndTime/SleepEmulator.bat index 60ea1bc..efe2539 100644 --- a/[02].DateAndTime/SleepEmulator.bat +++ b/[02].DateAndTime/SleepEmulator.bat @@ -1,4 +1,4 @@ -:: =============================================================================================== +:: =========================================================================================================== :: @file SleepEmulator.bat :: @brief Yet another sleep emulator working on everything from NT and above :: @syntax SleepEmulator.bat @@ -7,29 +7,29 @@ :: @see https://github.com/sebetci/batch.script/[02].DateAndTime/SleepEmulator.bat :: @reference https://www.robvanderwoude.com/wait.php :: @todo -:: =============================================================================================== +:: =========================================================================================================== @ECHO OFF :: If there isn't first parameter, exit the script. -IF "%~1"=="" GOTO :HELP +IF "%~1"=="" GOTO :FHELP :: If the first parameter isn't a number, exit the script. -ECHO.%*| FINDSTR /R /X /C:"[0-9][0-9]*" >NUL 2>NUL || GOTO :HELP +ECHO.%*| FINDSTR /R /X /C:"[0-9][0-9]*" >NUL 2>NUL || GOTO :FHELP :: If the first parameter is less than 0, exit the script. -IF %~1 LSS 0 GOTO :HELP +IF %~1 LSS 0 GOTO :FHELP :: The "typeperf" command writes performance counter data to the command window or to a supported log file format. TYPEPERF "\SYSTEM\PROCESSOR QUEUE LENGTH" -SI %~1 -SC 1 >NUL GOTO :EOF -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: @function This function prints the help menu on the screen. :: @parameter None :: @return None -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:HELP +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:FHELP ECHO Program Name: %~N0 ECHO Description: Wait for a specifier number of seconds ECHO Syntax: SleepEmulator.bat ^ diff --git a/[02].DateAndTime/W32DOW.bat b/[02].DateAndTime/W32DOW.bat index 50669a2..8260445 100644 --- a/[02].DateAndTime/W32DOW.bat +++ b/[02].DateAndTime/W32DOW.bat @@ -1,4 +1,4 @@ -:: =============================================================================================== +:: =========================================================================================================== :: @file W32DOW.bat :: @brief Prints the day of the week :: @syntax W32DOW.bat @@ -6,7 +6,7 @@ :: @reference https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/ff799054(v=ws.11) :: @reference https://en.wikipedia.org/wiki/W32tm :: @todo -:: =============================================================================================== +:: =========================================================================================================== @ECHO OFF SETLOCAL diff --git a/[02].DateAndTime/W32TMSleep.bat b/[02].DateAndTime/W32TMSleep.bat index 289d385..2aa3474 100644 --- a/[02].DateAndTime/W32TMSleep.bat +++ b/[02].DateAndTime/W32TMSleep.bat @@ -1,4 +1,4 @@ -:: =============================================================================================== +:: =========================================================================================================== :: @file W32TMSleep.bat :: @brief Yet another sleep emulator working on everything from NT and above :: @syntax W32TMSleep.bat @@ -8,18 +8,18 @@ :: @reference https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/ff799054(v=ws.11) :: @reference https://en.wikipedia.org/wiki/W32tm :: @todo -:: =============================================================================================== +:: =========================================================================================================== @ECHO OFF :: If there isn't first parameter, exit the script. -IF "%~1"=="" GOTO :HELP +IF "%~1"=="" GOTO :FHELP :: If the first parameter isn't a number, exit the script. -ECHO.%*| FINDSTR /R /X /C:"[0-9][0-9]*" >NUL 2>NUL || GOTO :HELP +ECHO.%*| FINDSTR /R /X /C:"[0-9][0-9]*" >NUL 2>NUL || GOTO :FHELP :: If the first parameter is less than 0, exit the script. -IF %~1 LSS 0 GOTO :HELP +IF %~1 LSS 0 GOTO :FHELP SETLOCAL SET /A VAdjust=%~1/2+1 @@ -31,12 +31,12 @@ SETLOCAL ENDLOCAL GOTO :EOF -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: @function This function prints the help menu on the screen. :: @parameter None :: @return None -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:HELP +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:FHELP ECHO Program Name: %~N0 ECHO Description: Wait for a specifier number of seconds ECHO Syntax: W32TMSleep.bat ^