Below is a command to open the Open with window for a file.
rundll32.exe setupapi,InstallHinfSection DefaultInstall 132The easiest way I found to do this was to edit the values on my machine locally then import them with Registry Wizard for creating new registry entries in Group Policy Management. rundll32 user32.dll,LockWorkStation Run the install for an inf file.
For Windows NT4: RUNDL元2 USER32.DLL,ExitWindowsEx RUNDL元2 USER32.DLL,ExitWindowsEx REM This is not a mistake, the command usually must be called twice before anything. When you set these string values the users will not be able to change their screen saver options for any of these values you set, they will be greyed out. We use RunDll32.exe user32.dll,LockWorkStation in conjunction through a GPO to accomplish this, works incredibly well for the civilization that firmly insist on leaving financial indevelopment on display and then leaving to make coffee HTH. For Windows 2000 and later versions we cannot, and don't need to use RUNDL元2: SHUTDOWN /L. The values you will want to copy, depending on what you want to change, are: ScreenSaveActive, ScreensaverIsSecure, ScreenSaveTimeOut, and SCRNSAVE.EXE. You can copy the string values directly from HKEY_CURRENT_USER\Control Panel\Desktop\ You will need to create a key "Control Panel" and another key under that "Desktop" so you will then have HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop The 2nd location is HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows There is a second place to edit in the registry that will override all settings. But changing this registry value manually does nothing. When you change them via display options inside Windows, this registry value is changed. I ended up ditching the GPO for screen saver, as it wasn't working and writing registry entries accomplished the same goal.įrom what I discovered, and it's really stupid, but even changing the HKEY_CURRENT_USER\Control Panel\Desktop\ registry settings for these values did nothing. I had a simlar problem, except it was that the screen saver would come on, but the time settings I had setup were not working, i.e. This causes the screensaver to only run for 30 seconds every 10 minutes.
As soon as Microsoft changes the path, an update of your program is needed and may leave your program unusable.
# Sleep for some time before checking againĮDIT: The only thing I need to improve in this script is that it will continue to lock the screen every 30 seconds after it is already locked. Process.Start(' C:WINDOWSsystem32rundll32.exe', ' user32.dll,LockWorkStation') This way of solving the problem is considered being a rather bad way, since the path to rundll32.exe is hard-coded in your programs code. $LockWorkStation::LockWorkStation() | Out-Null If (::IdleTime.TotalSeconds -gt $IdleTime) Public static extern bool = Add-Type -memberDefinition $signature -name "Win32LockWorkStation" -namespace Win32Functions -passthru Return Define DLL connection to lock screen Lii.cbSize = (uint)Marshal.SizeOf(typeof(LASTINPUTINFO)) Private static extern bool GetLastInputInfo(ref LASTINPUTINFO plii) ĭateTime bootTime = (-Environment.TickCount) ĭateTime lastInput = bootTime.AddMilliseconds(LastInputTicks)