Solved Batch file for Hibernate on/off with admin privilege.

Lautrec

New member
Local time
6:33 AM
Messages
15
Hi,

I trying to create a batch file for hibernate on/off.
I tried this:
echo off
:Ask
echo Activating Hibernate (Y/N)?
:INPUT
set /P INPUT=Type input: %=%
If /I "%INPUT%"=="y" goto yes
If /I "%INPUT%"=="n" goto no
echo Incorrect input & goto Ask
:yes
C:\Windows\System32\powercfg.exe /hibernate on
pause
:no
C:\Windows\System32\powercfg.exe /hibernate off
pause

But I want to use it without "right click -> Run As Admin."
Can you help me how to do this.

Thank you. :)
 

My Computer My Computer

OS
Windows 7 Ultimate
This batch script will prompt the user to run batch script with administrators privileges.

Code:
@echo off

Cd %TMP%

REM  --> Check for permissions
Reg query "HKU\S-1-5-19\Environment" 
REM --> If error flag set, we do not have admin.
if %errorlevel% NEQ 0 (
ECHO                 **************************************
ECHO                  Running Admin shell... Please wait...
ECHO                 **************************************

    goto UACPrompt
) else ( goto Ask )

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    set params = "%*:"=""
    echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"

    "%temp%\getadmin.vbs"
    del "%temp%\getadmin.vbs"
    exit /B


:Ask
Cls
echo Activating Hibernate (Y/N)?
:INPUT
set /P INPUT=Type input: %=%
If /I "%INPUT%"=="y" goto yes
If /I "%INPUT%"=="n" goto no
echo Incorrect input & goto Ask
:yes
C:\Windows\System32\powercfg.exe /hibernate on
pause
:no
C:\Windows\System32\powercfg.exe /hibernate off
pause
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Build
OS
Windows 10 Pro x64
CPU
Intel Core i5 6600
Motherboard
Gigabyte Technology Z170M-D3H-CF (U3E1)
Memory
Corsair Vengeance LPX 16GB 2666MHz DDR4
Graphics Card(s)
AMD Radeon R9 380 Series
Hard Drives
SSD
HDD
Antivirus
Eset Smart Security
Browser
Mozila Firefox
FreeBooter, thank you. :)
 

My Computer My Computer

OS
Windows 7 Ultimate
Some folks just love writing batch files as complicated as possible.

I like getting a job DONE, and not making it complicated.
KISS! (keep it simple stupid!)

I can't even imagine a case where I'd want to turn ON Hibernate, so I use just one simple little batch file to turn it OFF. I do know to right click on the batch file and "Run as Administrator".

@Echo off
cls
Rem: this program will disable Hibernation in windows 7/8.
powercfg -h off
Echo: Reboot. Then check for presence of Hiberfil.sys file in root directory.
pause

This is one of the first programs that I run when setting up a new install of Win-7.

Cheers Mate!
:cool:
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Various
OS
Win 7 Pro, SP1, x86, Win-11/Pro/64
CPU
AMD
Motherboard
Various
Memory
8GB Crucial
Graphics Card(s)
Various
Sound Card
OnBoard
Monitor(s) Displays
Acer 21.5"
Hard Drives
Crucial SSD, 500 GB
PSU
OEM
Case
SFF Slim Line Case
Cooling
OEM
Keyboard
eMachines
Mouse
Logitech Wireless
Internet Speed
varies
Antivirus
Windows Defender/Super Anti-Spyware
Browser
Firefox

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Build
OS
Windows 10 Pro x64
CPU
Intel Core i5 6600
Motherboard
Gigabyte Technology Z170M-D3H-CF (U3E1)
Memory
Corsair Vengeance LPX 16GB 2666MHz DDR4
Graphics Card(s)
AMD Radeon R9 380 Series
Hard Drives
SSD
HDD
Antivirus
Eset Smart Security
Browser
Mozila Firefox

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Home made Desktop
OS
Windows 10 Pro. 64/ version 1709 Windows 7 Pro/64
CPU
Intel i7-6800K @ 4.3
Motherboard
ASUS X-99 Deluxe II
Memory
Corsair Platinum 16 gig @2400
Graphics Card(s)
EVGA GTX 1070 OC
Monitor(s) Displays
Asus 27" LED LCD/VE278Q
Screen Resolution
1920-1080 or 1280-720 HDMI
Hard Drives
INTEL SSD 730-240 Gb Sata 3.0/
PSU
EVGA Platium 1200W
Case
Phanteks Luxe Tempered Glass 8 fans/ one radiator
Cooling
XSPC/ Water Cooled CPU
Keyboard
Das 4 Professional
Mouse
Logitech M705/MX Anywhere 2-S
Internet Speed
100 mbits
Antivirus
Microsoft Security Essentials/ Malwarebytes Premium 3.0/ SAS
Browser
I.E. 11 default/Firefox/ ISP Time Warner Cable/Spectrum
Other Info
LG BluRay Burner/
Sound system-KLipsch-THX/
Icy Dock ssd Hot Swap bays.
Back
Top