Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Change screensaver registry remotely...  (Read 41988 times)

0 Members and 1 Guest are viewing this topic.

patio

  • Moderator


  • Genius
  • Maud' Dib
  • Thanked: 1769
    • Yes
  • Experience: Beginner
  • OS: Windows 7
Re: Change screensaver registry remotely...
« Reply #15 on: June 10, 2009, 04:12:36 AM »
He mentioned disabling WMI on a group of machines in an earlier thread....
" Anyone who goes to a psychiatrist should have his head examined. "

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: Change screensaver registry remotely...
« Reply #16 on: June 10, 2009, 04:31:32 AM »
@BC, i didn't see OP's mentioned WMI is disabled (maybe i missed), if so, wouldn't the vbscript not work as it use WMI??

He mentioned disabling WMI on a group of machines in an earlier thread....

I remembered that myself, which is why I checked  :)







well, VBScript might be out- because- get this-


it uses WMI, and I believe you recently disabled that?

oh the irony!  :P

No that was on a different group of computers.  :P
I was trying to dereference Null Pointers before it was cool.

TheHoFL

    Topic Starter


    Intermediate

    Thanked: 5
    Re: Change screensaver registry remotely...
    « Reply #17 on: June 10, 2009, 09:36:15 AM »
    Thank you for the script BC_Programmer! I will give it a try.

    EDIT: I have been searching, but i don't think it's possible. Could i use a wildcard in the registry.


    I.E.
    Code: [Select]

    REG ADD "\\timscomputer\HKU\WILDCARD\Control Panel\Desktop" /V SCRNSAVE.EXE /T REG_SZ /F /D "%SystemRoot%\System32\newSS.scr"

    I have tried a few but it just create a string with that name.  :(
    « Last Edit: June 10, 2009, 10:46:12 AM by TheHoFL »
    All your dreams can come true if you have the courage to pursue them.  - Walt Disney

    TheHoFL

      Topic Starter


      Intermediate

      Thanked: 5
      Re: Change screensaver registry remotely...
      « Reply #18 on: June 10, 2009, 02:54:07 PM »
      Maybe i was doing it incorrectly. I am trying to get entry to be in every user profile. So i would need the script to somehow look up or place the reg key for every profile. Then i need to be able to add the computer names.

      Quote
      I.E. \\REMOTEPC\HKU\SID\Control Panel\Desktop" /V SCRNSAVE.EXE /T REG_SZ /F /D "%SystemRoot%\System32\ITEP SS_UTI Version.scr"
      REG ADD "\\REMOTEPC\HKU\SID\Control Panel\Desktop" /V ScreenSaveActive /T REG_SZ /F /D 1

      I just do not know how to have the code translate every SID to a user name. I did get it to work, just only for the ".DEFAULT" profile. This will only help me with new setups. I need to make these changes to computer that could have 20+ profiles on them. Any ideas?
      All your dreams can come true if you have the courage to pursue them.  - Walt Disney

      BC_Programmer


        Mastermind
      • Typing is no substitute for thinking.
      • Thanked: 1140
        • Yes
        • Yes
        • BC-Programming.com
      • Certifications: List
      • Computer: Specs
      • Experience: Beginner
      • OS: Windows 11
      Re: Change screensaver registry remotely...
      « Reply #19 on: June 10, 2009, 04:12:01 PM »
      your supposed to change:

      Code: [Select]
      Const NumMachines =2
      redim mmachinenames(NumMachines-1)

      'Change this portion, to reflect the actual number of machines (the above constant) as well as their names.
      mmachinenames(0) = "." 'this reflects the local machine. This was for my testing, change it :P
      mmachinenames(1) = "SATELLITE"

      that portion. right now, the mmachinesNames Array is being set to some test names (well, "." for local machine, and SATELLITE for my laptop.\\ change the 'NumMachines=2" to Nummachines=<number of PCs>, and mmachineNames to the proper PC names.

      Oh and I have a teensy mistake in my script:

      instead of
      Code: [Select]
      oReg.SetStringvalue HKEY_USERS,Strkeypath,"SCRNSAVE.EXE", "%SystemRoot%\System32\newSS.scr"

      this should be:
      Code: [Select]
      oReg.SetValue(HKEY_USERS, strkeypath, "SCRNSAVE.EXE", REG_EXPAND_SZ, "%SystemRoot%\System32\newSS.scr"




      I was trying to dereference Null Pointers before it was cool.

      TheHoFL

        Topic Starter


        Intermediate

        Thanked: 5
        Re: Change screensaver registry remotely...
        « Reply #20 on: June 10, 2009, 04:31:56 PM »
        Okay, i have make some changes. Also i cannot add it to HKCU, it needs to be in HKU. Can you please look over my changes? Do i need the underlined parts?

        Quote
        Sub SetKeysForMachine(Byval MachineName)
           const HKEY_USERS = &H80000003



           strComputer = MachineName
           Set StdOut = WScript.StdOut

           stdout.WriteLine "Connecting to " & machineName

           'Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
           'MachineName & "\root\default:StdRegProv")
           set oReg = GetObject("WinMgmts:{impersonationLevel=impersonate}!//" & strComputer & "/root/default:stdRegProv")
           strKeyPath = ""
           oReg.EnumKey HKEY_USERS, strKeyPath, arrSubKeys
            'REG ADD "\\timscomputer\HKCU\Control Panel\Desktop" /V SCRNSAVE.EXE /T REG_SZ /F /D "%SystemRoot%\System32\newSS.scr"

           'REG ADD "\\timscomputer\HKCU\Control Panel\Desktop" /V ScreenSaveActive /T REG_SZ /F /D 1
           For Each subkey In arrSubKeys

               'StdOut.WriteLine subkey
               'save subkey\Control Panel\Desktop value, screensaveactive.
              strKeyPath = subkey & "\Control Panel\Desktop"
              strValueName = "ScreenSaveActive"
              strValue = "1"
              oReg.SetStringValue HKEY_USERS,strKeyPath,strValueName,strValue

              oReg.SetValue(HKEY_USERS, strkeypath, "SCRNSAVE.EXE", REG_EXPAND_SZ, "%SystemRoot%\System32\newSS.scr"




           Next

        End Sub

        Dim mmachineNames()
        Const NumMachines =2
        redim mmachinenames(NumMachines-1)

        'Change this portion, to reflect the actual number of machines (the above constant) as well as their names.
        'mmachinenames(0) = "." 'this reflects the local machine. This was for my testing, change it :P
        mmachinenames(0) = "testpc"
        mmachinenames(1) = "imagepc"

        on error resume next
        Dim I ,X
        'for each machine in mmachinenames
        For I = 0 to ubound(mmachinenames)

           SetKeysForMachine mmachinenames(I)
           if err <> 0 then
                 wScript.stdOut.WriteLine "Error processing machine, " & mmachinenames(I)
           Else
           X=X+1
           end if
        next

        wScript.stdOut.WriteLine "Script finished. Successfully processed " & X & " of " & ubound(mmachinenames)+1 & " Machines."
        All your dreams can come true if you have the courage to pursue them.  - Walt Disney

        BC_Programmer


          Mastermind
        • Typing is no substitute for thinking.
        • Thanked: 1140
          • Yes
          • Yes
          • BC-Programming.com
        • Certifications: List
        • Computer: Specs
        • Experience: Beginner
        • OS: Windows 11
        Re: Change screensaver registry remotely...
        « Reply #21 on: June 10, 2009, 04:35:55 PM »
        you need the third underlined line. the first two are comments- they start with '.

        I had them there, so I could remember what the keys where you wanted changed.

        remember if you have more then 2 machines you can change the constant (Const NumMachines =2) to a higher number and add them where you now have "testpc" and "imagepc".


        If net view reveals the names of the PCs you want to change somebody clever in the use of batch might be able to generate a base listing through manipulation of that output.
        I was trying to dereference Null Pointers before it was cool.

        TheHoFL

          Topic Starter


          Intermediate

          Thanked: 5
          Re: Change screensaver registry remotely...
          « Reply #22 on: June 10, 2009, 05:01:23 PM »
          Now i am getting an error:

          All your dreams can come true if you have the courage to pursue them.  - Walt Disney

          BC_Programmer


            Mastermind
          • Typing is no substitute for thinking.
          • Thanked: 1140
            • Yes
            • Yes
            • BC-Programming.com
          • Certifications: List
          • Computer: Specs
          • Experience: Beginner
          • OS: Windows 11
          Re: Change screensaver registry remotely...
          « Reply #23 on: June 10, 2009, 05:05:04 PM »
          what is the entire script as it is now?
          I was trying to dereference Null Pointers before it was cool.

          TheHoFL

            Topic Starter


            Intermediate

            Thanked: 5
            Re: Change screensaver registry remotely...
            « Reply #24 on: June 10, 2009, 05:10:28 PM »
            It says the error is in line 27. Here is line 27.
            Code: [Select]
            oReg.SetValue(HKEY_USERS, strkeypath, "SCRNSAVE.EXE", REG_EXPAND_SZ, "%SystemRoot%\System32\ITEP SS_UTI Version.scr"
            Thank you so much for your assistance by the way! Do i actually need to change the "strikeypath" or do i leave that there?

            Code: ... i changed file names and the test computer.

            Code: [Select]
            Sub SetKeysForMachine(Byval MachineName)
            const HKEY_USERS = &H80000003



            strComputer = MachineName
            Set StdOut = WScript.StdOut

            stdout.WriteLine "Connecting to " & machineName

            'Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
            'MachineName & "\root\default:StdRegProv")
            set oReg = GetObject("WinMgmts:{impersonationLevel=impersonate}!//" & strComputer & "/root/default:stdRegProv")
            strKeyPath = ""
            oReg.EnumKey HKEY_USERS, strKeyPath, arrSubKeys
            'REG ADD "\\timscomputer\HKCU\Control Panel\Desktop" /V SCRNSAVE.EXE /T REG_SZ /F /D "%SystemRoot%\System32\ITEP SS_UTI Version.scr"

            'REG ADD "\\timscomputer\HKCU\Control Panel\Desktop" /V ScreenSaveActive /T REG_SZ /F /D 1
            For Each subkey In arrSubKeys
                'StdOut.WriteLine subkey
                'save subkey\Control Panel\Desktop value, screensaveactive.
            strKeyPath = subkey & "\Control Panel\Desktop"
            strValueName = "ScreenSaveActive"
            strValue = "1"
            oReg.SetStringValue HKEY_USERS,strKeyPath,strValueName,strValue

            oReg.SetValue(HKEY_USERS, strkeypath, "SCRNSAVE.EXE", REG_EXPAND_SZ, "%SystemRoot%\System32\ITEP SS_UTI Version.scr"




            Next

            End Sub

            Dim mmachineNames()
            Const NumMachines =1
            redim mmachinenames(NumMachines-1)

            'Change this portion, to reflect the actual number of machines (the above constant) as well as their names.
            'mmachinenames(0) = "." 'this reflects the local machine. This was for my testing, change it :P
            mmachinenames(0) = "u1jbennett"
            on error resume next
            Dim I ,X
            'for each machine in mmachinenames
            For I = 0 to ubound(mmachinenames)

            SetKeysForMachine mmachinenames(I)
            if err <> 0 then
            wScript.stdOut.WriteLine "Error processing machine, " & mmachinenames(I)
            Else
            X=X+1
            end if
            next

            wScript.stdOut.WriteLine "Script finished. Successfully processed " & X & " of " & ubound(mmachinenames)+1 & " Machines."
            All your dreams can come true if you have the courage to pursue them.  - Walt Disney

            BC_Programmer


              Mastermind
            • Typing is no substitute for thinking.
            • Thanked: 1140
              • Yes
              • Yes
              • BC-Programming.com
            • Certifications: List
            • Computer: Specs
            • Experience: Beginner
            • OS: Windows 11
            Re: Change screensaver registry remotely...
            « Reply #25 on: June 10, 2009, 05:18:34 PM »
            ok, found the problem. also fixed something else.

            Code: [Select]
            Sub SetKeysForMachine(Byval MachineName)
            const HKEY_USERS = &H80000003



            strComputer = MachineName
            Set StdOut = WScript.StdOut

            stdout.WriteLine "Connecting to " & machineName

            'Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
            'MachineName & "\root\default:StdRegProv")
            set oReg = GetObject("WinMgmts:{impersonationLevel=impersonate}!//" & strComputer & "/root/default:stdRegProv")
            strKeyPath = ""
            oReg.EnumKey HKEY_USERS, strKeyPath, arrSubKeys
            'REG ADD "\\timscomputer\HKCU\Control Panel\Desktop" /V SCRNSAVE.EXE /T REG_SZ /F /D "%SystemRoot%\System32\ITEP SS_UTI Version.scr"

            'REG ADD "\\timscomputer\HKCU\Control Panel\Desktop" /V ScreenSaveActive /T REG_SZ /F /D 1
            For Each subkey In arrSubKeys
                'StdOut.WriteLine subkey
                'save subkey\Control Panel\Desktop value, screensaveactive.
            strKeyPath = subkey & "\Control Panel\Desktop"
            strValueName = "ScreenSaveActive"
            strValue = "1"
            oReg.SetStringValue HKEY_USERS,strKeyPath,strValueName,strValue
            'Next line was changed:


            oReg.SetValue(HKEY_USERS, strkeypath, "SCRNSAVE.EXE", REG_EXPAND_SZ, """%SystemRoot%\System32\ITEP SS_UTI Version.scr""")




            Next

            End Sub

            Dim mmachineNames()
            Const NumMachines =1
            redim mmachinenames(NumMachines-1)

            'Change this portion, to reflect the actual number of machines (the above constant) as well as their names.
            'mmachinenames(0) = "." 'this reflects the local machine. This was for my testing, change it :P
            mmachinenames(0) = "u1jbennett"
            on error resume next
            Dim I ,X
            'for each machine in mmachinenames
            For I = 0 to ubound(mmachinenames)

            SetKeysForMachine mmachinenames(I)
            if err <> 0 then
            wScript.stdOut.WriteLine "Error processing machine, " & mmachinenames(I)
            Else
            X=X+1
            end if
            next

            wScript.stdOut.WriteLine "Script finished. Successfully processed " & X & " of " & ubound(mmachinenames)+1 & " Machines."


            this is the new line:

            Code: [Select]
            oReg.SetValue(HKEY_USERS, strkeypath, "SCRNSAVE.EXE", REG_EXPAND_SZ, """%SystemRoot%\System32\ITEP SS_UTI Version.scr""")
            it didn't have a ) at the end. Also, since it has spaces, it will need to be quoted when placed in the registry. two quotes in a VBScript string equal one, which is why it has three on each end. Also, is the path correct? is the Screensaver in System32, or in a folder called "ITEP" in system32? (just checking ;))
            I was trying to dereference Null Pointers before it was cool.

            TheHoFL

              Topic Starter


              Intermediate

              Thanked: 5
              Re: Change screensaver registry remotely...
              « Reply #26 on: June 10, 2009, 05:25:09 PM »
              The name of the file is "ITEP SS_UTI Version.scr" ... not my decision or there would be no spaces...

              I am getting another error on the same line now. I didn't change anything this time.  ;)

              error:
              All your dreams can come true if you have the courage to pursue them.  - Walt Disney

              BC_Programmer


                Mastermind
              • Typing is no substitute for thinking.
              • Thanked: 1140
                • Yes
                • Yes
                • BC-Programming.com
              • Certifications: List
              • Computer: Specs
              • Experience: Beginner
              • OS: Windows 11
              Re: Change screensaver registry remotely...
              « Reply #27 on: June 10, 2009, 05:27:21 PM »
              woops, my bad. Guess I' just too used to the VB6 IDE fixing these types of mistakes for me!  :P


              change:

              Code: [Select]
              oReg.SetValue(HKEY_USERS, strkeypath, "SCRNSAVE.EXE", REG_EXPAND_SZ, """%SystemRoot%\System32\ITEP SS_UTI Version.scr""")


              to

              Code: [Select]
              oReg.SetValue HKEY_USERS, strkeypath, "SCRNSAVE.EXE", REG_EXPAND_SZ, """%SystemRoot%\System32\ITEP SS_UTI Version.scr"""

              I was trying to dereference Null Pointers before it was cool.

              TheHoFL

                Topic Starter


                Intermediate

                Thanked: 5
                Re: Change screensaver registry remotely...
                « Reply #28 on: June 10, 2009, 05:37:57 PM »
                Okay, now there are no errors. Now the issue is that i went to the machine that it should have changed and it did not change it. Any ideas? It should change the screen saver for every user even if the profile exists.

                Thank you again for the help!

                EDIT: when you double click the VBS it does not flash anything, it just has the "busy" mouse for a second.
                All your dreams can come true if you have the courage to pursue them.  - Walt Disney

                BC_Programmer


                  Mastermind
                • Typing is no substitute for thinking.
                • Thanked: 1140
                  • Yes
                  • Yes
                  • BC-Programming.com
                • Certifications: List
                • Computer: Specs
                • Experience: Beginner
                • OS: Windows 11
                Re: Change screensaver registry remotely...
                « Reply #29 on: June 10, 2009, 06:06:56 PM »
                well- you should instead run it via the command line, using cscript.

                this way it will report any issues changing the registry keys and/or connecting to the remote PC.

                Also make sure that the remote PC has that set of keys permissions set to "full control" for "everybody".
                I was trying to dereference Null Pointers before it was cool.