Скрипт для поиска «.exe» и «.msi» Часть II - PullRequest
0 голосов
/ 04 октября 2018

My Script не фильтрует «Program Files» и «WinNT» при сканировании, и скрипт Timer не может работать вообще.

@Echo Off
@Echo Scanning In Progress... This Will Take Several Time!! 
Setlocal EnableExtensions EnableDelayedExpansion
set starttime=%time%

cd\
set Directory=Directory
set Date Created=Date Created
set Date Modified=Date Modified
set Date Accessed=Date Accessed
set FileName=FileName

Echo %Directory%,%Date Created%,%Date Modified%,%Date Accessed%,%FileName% >>c:\users\user\desktop\Result.csv

For /r "c:\" %%a in ("*.exe" "*.msi") DO (
set "d=%%a"
if /i not "!d:~0,17!"=="c:\program files\" if /i not "!d:~0,9!"=="c:\WinNT\" (
@Echo %%a
For /f "tokens=1-4 delims=] " %%b in ('dir /tc "%%a" ^|find /n " "    ^|find "[6]"') DO SET "datecreated=%%c  %%d%%e"
For /f "tokens=1-4 delims=] " %%f in ('dir /tw "%%a" ^|find /n " " ^|find "[6]"') DO SET "datemodified=%%g  %%h%%i"
For /f "tokens=1-4 delims=] " %%j in ('dir /ta "%%a" ^|find /n " " ^|find "[6]"') DO SET "dateaccessed=%%k  %%l%%m"
For /f "tokens=6 delims=] " %%n in ('dir /tc "%%a" ^|find /n " " ^|find "[6]"') DO SET "filename=%%n"

Echo "%%a",!datecreated!,!datemodified!,!dateaccessed!,!filename! >>c:\users\user\desktop\Result.csv 
)
)
set endtime=%time%

set /a hrs=%endtime:~0,2%
set /a hrs=%hrs%-%starttime:~0,2%

set /a mins=%endtime:~3,2%
set /a mins=%mins%-%starttime:~3,2%

set /a secs=%endtime:~6,2%
set /a secs=%secs%-%starttime:~6,2%

if %secs% lss 0 (
    set /a secs=!secs!+60
    set /a mins=!mins!-1
)
if %mins% lss 0 (
    set /a mins=!mins!+60
    set /a hrs=!hrs!-1
)
if %hrs% lss 0 (
    set /a hrs=!hrs!+24
)
set /a tot=%secs%+%mins%*60+%hrs%*3600

Echo Start = %starttime%
Echo End   = %endtime%
Echo Hours = %hrs%
Echo Minutes = %mins%
Echo Seconds = %secs%
Echo Total = %tot%
Echo Scanning Progress Compeleted!!
Endlocal 
@pause
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...