I have a batch file that automatically sets the computer to sleep after 0 minutes (aka never sleep). Then I want to set it back to what it was before. My question is how would I set the current sleep time to a variable before I turn it off? Thanks in advance!
CLARIFICATION: I'm new to batch so feel free to point stuff out. Here's my current script:
@echo off
tasklist /v | find "Server" > nul
if errorlevel 1 (
title Server
set "time=[WHAT DO I PUT HERE?]" ::Gather current value for "put the computer to sleep:"
C:
cd C:windows\system32\powercfg.exe -change -standby-timeout-ac 0 ::Set the computer's sleep time to 0 (off)
D:
cd D:/Users/Elijah/Desktop/Tekkit_Server_v1.2.9g/ ::Do tasks
java -Xmx12G -Xms10G -jar Tekkit.jar nogui
cd C:windows\system32\powercfg.exe -change -standby-timeout-ac %time% ::When that's done, change the sleep setting back to what it was before we set it to 0
title Server [STOPPED]
pause
) else ( ::If bad stuff happens
title Server [FAILED]
echo A server is already running
pause
)
I want to use this script for some automation with a Minecraft server. When I run a server from my computer, I have to change the "put the computer to sleep" setting to 0 minutes in control panel. I have already set this up in the script, but now my problem is turning auto-sleep back on and setting to what it was before. So to do that I want to store the value in a variable called time
. How would I do that?