windows_batch_scripting
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| windows_batch_scripting [2015/07/23 15:15] – add Escape an exclamation mark when EnableDelayedExpansion is active zertrin | windows_batch_scripting [2015/08/04 20:18] (current) – add "Delete folders older than 10 days" zertrin | ||
|---|---|---|---|
| Line 96: | Line 96: | ||
| </ | </ | ||
| ++++ | ++++ | ||
| + | |||
| + | ==== Check if the current batch script has admin rights ==== | ||
| + | |||
| + | from http:// | ||
| + | |||
| + | < | ||
| + | @echo off | ||
| + | goto check_Permissions | ||
| + | |||
| + | : | ||
| + | echo Administrative permissions required. Detecting permissions... | ||
| + | |||
| + | net session >nul 2>&1 | ||
| + | if %errorLevel% == 0 ( | ||
| + | echo Success: Administrative permissions confirmed. | ||
| + | ) else ( | ||
| + | echo Failure: Current permissions inadequate. | ||
| + | ) | ||
| + | |||
| + | pause >nul | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== Get current time in a locale independent way ==== | ||
| + | |||
| + | from http:// | ||
| + | |||
| + | < | ||
| + | FOR /f %%a in ('WMIC OS GET LocalDateTime ^| find " | ||
| + | set CUR_DATE=%DTS: | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== Delete folders older than 10 days ==== | ||
| + | |||
| + | from http:// | ||
| + | |||
| + | < | ||
| + | FORFILES /S /D -10 /C "cmd /c IF @isdir == TRUE rd /S /Q @path" | ||
| + | </ | ||
| + | |||
windows_batch_scripting.1437635745.txt.gz · Last modified: by zertrin
