Skip to content

Instantly share code, notes, and snippets.

@rampageX
Last active August 29, 2024 14:56
Show Gist options
  • Save rampageX/576a2ed279c065e4686f11549b31cab1 to your computer and use it in GitHub Desktop.
Save rampageX/576a2ed279c065e4686f11549b31cab1 to your computer and use it in GitHub Desktop.

Revisions

  1. rampageX renamed this gist Aug 29, 2024. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. rampageX created this gist Aug 29, 2024.
    59 changes: 59 additions & 0 deletions bat
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,59 @@
    :: 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"
    )
    )
    )
    :--------------------------------------