none
Get Screensaver timeout values does not return correct value RRS feed

  • Question

  • Screen saver settings are set by GPO policy. For all users on the all the client machines in the network but i always get a 0 for timeout even though value is greater than 0. Checking the registry, i can see the key I’d expect to be set for the user (hkcu\control panel\desktop\screensavetimeout / hku\sid\Control panel\Desktop\Screensavetimeout)

    To make sure the SID filter wasn’t catching me out I left it as a pattern match for .* and confirmed that a number of users were enumerated but in each case the screensaver timer = 0 even although values are set greater than 0.

    I cannot use powershell otherwise it would be much easier, i guess. Anyone have any ideas why WMI wouldn’t retrieve the same values as a straight registry key check in this case / why the test would fail to retrieve the values expected?

    On Error Resume Next

    Const wbemFlagReturnImmediately = &h10

    Const wbemFlagForwardOnly = &h20

    Set wshNetwork = WScript.CreateObject("WScript.Network")

    strComputer = wshNetwork.ComputerName

    strQuery = "SELECT * FROM Win32_Desktop"

    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\ROOT\CIMV2")

    Set colItems = objWMIService.ExecQuery(strQuery, "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)

    For Each objItem in colItems

        WScript.StdOut.WriteLine "ScreenSaverActive: " & objItem.ScreenSaverActive

        WScript.StdOut.WriteLine "ScreenSaverExecutable: " & objItem.ScreenSaverExecutable

        WScript.StdOut.WriteLine "ScreenSaverSecure: " & objItem.ScreenSaverSecure

        WScript.StdOut.WriteLine "ScreenSaverTimeout: " & objItem.ScreenSaverTimeout

        WScript.StdOut.WriteLine ""

    Next

    Thank you.

    Tuesday, October 31, 2017 5:34 PM

Answers

  • It's not possible to "remove" PowerShell on Windows versions newer than Vista because it is a built-in and default part of the OS starting with Windows 7.

    (Aside from that, even if you could somehow "remove" PowerShell, what would you gain by doing so?)


    -- Bill Stewart [Bill_Stewart]

    Tuesday, October 31, 2017 7:22 PM
    Moderator

All replies

  • Start by removing "On Error" then fix the errors.

    You cannot get the GPO setting from that class.  GPO will override any local settings.

    Use GPResult to check if settings are being applied correctly.


    \_(ツ)_/

    Tuesday, October 31, 2017 5:46 PM
  • This will do the same thing in PowerShell in one line:

    Get-WmiObject win32_desktop


    \_(ツ)_/

    Tuesday, October 31, 2017 5:51 PM
  • Why can't you use PowerShell?

    -- Bill Stewart [Bill_Stewart]

    Tuesday, October 31, 2017 6:07 PM
    Moderator
  • They have removed the powershell. It is not allowed.
    Tuesday, October 31, 2017 6:26 PM
  • You cannot remove or disable PowerShell in modern Windows.  It is part of the operating system.  Just type powershell at a prompt.


    \_(ツ)_/

    Tuesday, October 31, 2017 6:43 PM
  • It's not possible to "remove" PowerShell on Windows versions newer than Vista because it is a built-in and default part of the OS starting with Windows 7.

    (Aside from that, even if you could somehow "remove" PowerShell, what would you gain by doing so?)


    -- Bill Stewart [Bill_Stewart]

    Tuesday, October 31, 2017 7:22 PM
    Moderator