Step 1: Create a Batch File and place it inside C:\scripts
@echo off powercfg.exe -x -monitor-timeout-ac 0 powercfg.exe -x -monitor-timeout-dc 0 powercfg.exe -x -disk-timeout-ac 0 powercfg.exe -x -disk-timeout-dc 0 powercfg.exe -x -standby-timeout-ac 0 powercfg.exe -x -standby-timeout-dc 0 powercfg.exe -x -hibernate-timeout-ac 0 powercfg.exe -x -hibernate-timeout-dc 0
Step 2: Create a PowerShell file in the same directory and place a shortcut on the Desktop
var startProcess = new System.Diagnostics.ProcessStartInfo(); newProcessInfo.FileName = @"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"; startProcess.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; # run in the background startProcess.Verb = "runas"; # run as [administrator] startProcess.Arguments = @"-executionpolicy unrestricted -Command ""C:\scripts\powercfg.bat -noexit"""; # set powershell switches to call the batch files to run unrestricted. Remove the -noexit item to close the window automatically after each run time System.Diagnostics.Process.Start(startProcess); # Trigger the start command to instantiate and bowow
Categories: