powershell script to keep windows awake
- User
powershell script to keep windows awake
- Assistant
Creating a PowerShell script to keep your Windows machine awake is relatively straightforward. One common way to do this is by using the
Powercfgcommand to temporarily disable sleep mode or by simulating user activity to prevent the system from going idle. Below is a simple example usingStart-Sleepin conjunction with a continuous loop to achieve the latter method: - User
Unable to find type [System.Windows.Forms.Cursor]. At C:\Users\gouth\OneDrive\Desktop\File.ps1:8 char:5
-
[System.Windows.Forms.Cursor]::Position = [System.Drawing.Point]: ... -
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- CategoryInfo : InvalidOperation: (System.Windows.Forms.Cursor:TypeName) [], RuntimeException
- FullyQualifiedErrorId : TypeNotFound Error found while running the script
-
- Assistant
The error message indicates that the
System.Windows.Forms.Cursortype could not be found. This usually happens when the necessary assembly (System.Windows.Forms) is not loaded into the PowerShell session. The assembly provides the classes required to handle Windows Forms, including the mouse cursor.