Last active
August 29, 2024 14:56
-
-
Save rampageX/576a2ed279c065e4686f11549b31cab1 to your computer and use it in GitHub Desktop.
This program will run "smartctl.exe -n standby X:" on all HDD drives in an unattended manner.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: BatchGotAdmin <https://sites.google.com/site/eneerge/scripts/batchgotadmin> | |
:------------------------------------- | |
@echo off | |
REM --> Check for permissions | |
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" | |
REM --> If error flag set, we do not have admin. | |
if '%errorlevel%' NEQ '0' ( | |
echo Requesting administrative privileges... | |
goto UACPrompt | |
) else ( goto gotAdmin ) | |
:UACPrompt | |
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" | |
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs" | |
"%temp%\getadmin.vbs" | |
exit /B | |
:gotAdmin | |
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" ) | |
pushd "%CD%" | |
CD /D "%~dp0" | |
@echo on | |
:-------------------------------------- | |
:: StandBy Checker::PrintInfo <[email protected]> (c) 2015 BSD-Clause 3 | |
:-------------------------------------- | |
@echo off | |
echo. | |
echo == Disk StandBy Checker == | |
echo (C) 2024 "<[email protected]>" BSD-Clause 3 | |
echo. | |
echo This program will run "smartctl.exe -n standby X:" on all HDD drives in an unattended manner. | |
echo. | |
echo Press ANY KEY to continue... | |
echo. | |
pause>nul | |
:-------------------------------------- | |
:: StandBy Checker <[email protected] (c) 2014-2015 BSD-Clause 3> | |
:-------------------------------------- | |
@echo off | |
setlocal enabledelayedexpansion | |
REM ^, -- ^ is the escape character for declarations between ' | |
echo checking.....(a SPINNING drive reports: Device is in ACTIVE or IDLE mode) | |
for /f "skip=1" %%a in ('wmic logicaldisk get caption') do ( | |
set isHDD= | |
for /f "tokens=*" %%i in ('smartctl.exe -a %%a ^| findstr "Rotation Rate:"') do set isHDD=%%i | |
if not "!isHDD!"=="" ( | |
echo.!isHDD!| find /i "rpm">nul && ( | |
echo | set /p="%%a " | |
smartctl.exe -n standby %%a | findstr "Device" | |
) | |
) | |
) | |
:-------------------------------------- |
::smartctl.exe -s standby,now d:
::smartctl 6.5 2016-05-07 r4318 [x86_64-w64-mingw32-win10] (sf-6.5-1)
::Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
::Device placed in STANDBY mode
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
smartctl.exe -a %%a
will wakeup sleep disk, so this script is useless.