How to stop computer from sleeping

 


This is a very generic post, but I felt though this is small thing but can be of good use. So, many times we do run the PowerShell scripts or some processing on our local computer and it is blocked due to the system entering into sleep mode.

Due to which the process gets stopped. There are third-party apps for this but do not rely on installing many 3rd party apps to my system. So I found the script which does the job for me. I know what's written in the script so I am confident while running this script.

Here is the script,

Clear-Host
$myshell = New-Object -com "Wscript.Shell"

while ($true) {
    Write-Host ([char]9829-ForegroundColor Red -NoNewline
    $myshell.sendkeys(".")
    Start-Sleep -Seconds 300
}


Hope this will help you as well, do comment and share if you like it.


Happy Coding..!!

Sumit Kanchan

Comments

Popular posts from this blog

Sorting in Typescript (Simple Arrays & Array of Objects)

SharePoint Framework (SPFx) Tab Control (react)

SPFx Chat Bot - using SharePoint Framework Extension