IT controls one of the machines I use. There is an idle timeout of 30 minutes on it…
Rate quality
Private research annotation
Sign in to add a private research label or note.
- User
IT controls one of the machines I use. There is an idle timeout of 30 minutes on it where it logs off the person. They stated that it shouldn;t happen if an application is running. I have an application running which continuosily updates the window running the app and the log. How do I update my application to prevent windows from trigging the idle timeout?
Assistant
- User
is there a pwershell script that can do this?
Assistant
Yes, here's a PowerShell script that can simulate user activity to prevent idle timeout:
powershell# Set the interval (in seconds) between activity simulations. $Interval = 1500 # 25 minutes while ($true) { # Simulate a key press (e.g., the Num Lock key). [System.Windows.Forms.SendKeys]::SendWait("{NUMLOCK}") # Wait for the specified interval. Start-Sleep -Seconds $Interval }- User
Unable to find type [System.Windows.Forms.SendKeys]. At line:3 char:5
-
code
[System.Windows.Forms.SendKeys]::SendWait("{NUMLOCK}") -
code
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- CategoryInfo : InvalidOperation: (System.Windows.Forms.SendKeys:TypeName) [], RuntimeException
- FullyQualifiedErrorId : TypeNotFound
-
Assistant
The error "Unable to find type [System.Windows.Forms.SendKeys]" usually occurs because the required assembly for
System.Windows.Formsisn't loaded in the PowerShell session. Here's how you can fix it:Solution:
Add the following line at the beginning of your PowerShell script:
powershellAdd-Type -AssemblyName System.Windows.FormsComplete Script with the Fix:
powershell