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 41986 times)

0 Members and 1 Guest are viewing this topic.

TheHoFL

    Topic Starter


    Intermediate

    Thanked: 5
    Re: Change screensaver registry remotely...
    « Reply #30 on: June 11, 2009, 10:19:43 AM »
    Ok, i ran it from a BAT file and here is the results ...

    Quote
            1 file(s) copied.
    Press any key to continue . . .
    Microsoft (R) Windows Script Host Version 5.7
    Copyright (C) Microsoft Corporation. All rights reserved.

    Connecting to u1jbennett
    Error processing machine, u1jbennett
    Script finished. Successfully processed  of 1 Machines.
    Press any key to continue . . .

    Why would it say this
    Quote
    Error processing machine, u1jbennett
    ??


    EDIT: I checked the registry on the remote machine and the registry for those setting were not changed.
    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 #31 on: June 11, 2009, 10:22:42 AM »
    probably, a permission denied error.

     by default, XP only let's remote PC's Look at it's registry keys, not change them.


     But, the problem here, is that you would need to somehow change the permissions on all the machines, which would kind of make the script a moot point, unless you can find a way to automate that, as well.  :(
    I was trying to dereference Null Pointers before it was cool.

    TheHoFL

      Topic Starter


      Intermediate

      Thanked: 5
      Re: Change screensaver registry remotely...
      « Reply #32 on: June 11, 2009, 10:31:00 AM »
      I am part of a domain admin group in AD. That group is the "administrators" group on the local machines. Wouldn't that give me the proper rights to the machine? Do you think there would be any difference if it was run from the DC?

      I shouldn't need to use any of the switches i don't think...
      Quote
      Usage: CScript scriptname.extension [option...] [arguments...]
      Options:
       //B         Batch mode: Suppresses script errors and prompts from displaying
       //D         Enable Active Debugging
       //E:engine  Use engine for executing script
       //H:CScript Changes the default script host to CScript.exe
       //H:WScript Changes the default script host to WScript.exe (default)
       //I         Interactive mode (default, opposite of //B)
       //Job:xxxx  Execute a WSF job
       //Logo      Display logo (default)
       //Nologo    Prevent logo display: No banner will be shown at execution time
       //S         Save current command line options for this user
       //T:nn      Time out in seconds:  Maximum time a script is permitted to run
       //X         Execute script in debugger
       //U         Use Unicode for redirected I/O from the console

      This is the line that i have to call the script:
      Code: [Select]
      cscript "%~dp0\Itep_SS.vbs"
      I noticed in the script there is a part that looks undefined...could that have something to do with it?
      Code: [Select]
      strKeyPath = ""
      « Last Edit: June 11, 2009, 10:59:41 AM by TheHoFL »
      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 #33 on: June 11, 2009, 04:29:06 PM »
      I am part of a domain admin group in AD. That group is the "administrators" group on the local machines. Wouldn't that give me the proper rights to the machine? Do you think there would be any difference if it was run from the DC?

      well, both the accounts on my laptop and my desktop were logged in as administrator, and it still gave me permission denied. we can find out exactly what the error number is though, to confirm.

      change the line:

      Code: [Select]
      wScript.stdOut.WriteLine "Error processing machine, " & mmachinenames(I)

      to

      Code: [Select]
      wScript.stdOut.WriteLine "Error processing machine, " & mmachinenames(I) & " error: " & err



      Quote
      I noticed in the script there is a part that looks undefined...could that have something to do with it?
      Code: [Select]
      strKeyPath = ""

      Nope... that was on purpose.
      I was trying to dereference Null Pointers before it was cool.

      TheHoFL

        Topic Starter


        Intermediate

        Thanked: 5
        Re: Change screensaver registry remotely...
        « Reply #34 on: June 11, 2009, 04:43:16 PM »
        Alright, I just changed it and ran the BAT that calls it.

        Here is the results:

        Quote
                1 file(s) copied.
        Press any key to continue . . .
        Microsoft (R) Windows Script Host Version 5.7
        Copyright (C) Microsoft Corporation. All rights reserved.

        Connecting to u1jbennett
        Error processing machine, u1jbennett error: 438
        Script finished. Successfully processed  of 1 Machines.
        Press any key to continue . . .

        I looked it up and this was the description:
        Quote
        Object doesn't support this property or method
        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 #35 on: June 11, 2009, 04:52:33 PM »
        ahh, 438.

        odd.

        Quote
        Object doesn't support this property or method

        Strange.

        I tried the same script, changed the names of the PCs, and I got error 70 again, Permission denied.

        There might be, a mistake copying it, though, the name of a method or somesuch.

        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 KEY_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) = "Satellite"
        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) & "Error:" & ERR 
        Else
        X=X+1
        end if
        next

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

        Also, make sure the WMI service "Windows Management Instrumentation" is running on both PCs.


        I'll say this, this seemingly simply problem is becoming a real doozy!
        I was trying to dereference Null Pointers before it was cool.

        TheHoFL

          Topic Starter


          Intermediate

          Thanked: 5
          Re: Change screensaver registry remotely...
          « Reply #36 on: June 11, 2009, 04:56:32 PM »
          Weird ... i copied the script you posted in your last post and this is what returned.

          Quote
                  1 file(s) copied.
          Press any key to continue . . .
          Microsoft (R) Windows Script Host Version 5.7
          Copyright (C) Microsoft Corporation. All rights reserved.

          Connecting to Satellite
          Error processing machine, SatelliteError:70
          Press any key to continue . . .

          And i made sure WMI was enabled.

          You are totally correct... this is becoming a major pain! Thank you for helping me!  ;D
          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 #37 on: June 11, 2009, 04:58:30 PM »
          hmm... you got permission denied.

          But this time- you tried to connect to a fictitious "Satellite" on your network  :P

          Sorry I had to change the PC name back to SATELLITE to test it over here. Try changing it back and see if you get the previous, 438 error again.
          I was trying to dereference Null Pointers before it was cool.

          TheHoFL

            Topic Starter


            Intermediate

            Thanked: 5
            Re: Change screensaver registry remotely...
            « Reply #38 on: June 11, 2009, 05:06:00 PM »
            I am sorry i didn't notice you changed that. I am running on 4 hours of sleep today and it is catching up with me.  :-[ I changed it back and received the same error:

            Quote
            Connecting to u1jbennett
            Error processing machine, u1jbennettError:438
            Press any key to continue . . .
            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 #39 on: June 11, 2009, 05:25:14 PM »
            well, I'll be honest...

            I haven't got a clue what the heck is going on. the error made me think it was simply a typing mistake or something similar, but that isn't the case.

            I did a few quick googles and the onlything I can think of, is if the other PC is running an OS before windows XP, the error might occur.
            I was trying to dereference Null Pointers before it was cool.

            TheHoFL

              Topic Starter


              Intermediate

              Thanked: 5
              Re: Change screensaver registry remotely...
              « Reply #40 on: June 11, 2009, 05:29:15 PM »
              Bummer! Both are running XP Pro.

              Well thank you soo much for your time! I really do appreciate it.  ;D
              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 #41 on: June 11, 2009, 05:36:57 PM »
              Well, last ditch idea, is I could try to write a little VB6 program. Maybe my Registry class can cut through this WMI crap. It's written right to the API, none of this obtuse error crap.  ;D
              I was trying to dereference Null Pointers before it was cool.

              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 #42 on: June 11, 2009, 05:50:02 PM »
              ...

              Well, I had it, but it gave me an idea, what is happening in the script.

              When I debugged it, I found, that it was able to add the new key to every USER, except one, where it failed.

              In my haste, I've forgotten that even the administrator is lower then the "SYSTEM" account, so chances are it crashes there.


              I will add some error handling into the area where it loops through each one:


              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

              On Error Resume Next
              For Each subkey In arrSubKeys
              Err.clear
                  '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 KEY_USERS, strkeypath, "SCRNSAVE.EXE", REG_EXPAND_SZ, """%SystemRoot%\System32\ITEP SS_UTI Version.scr"""

              If Err <> 0 then
              stdout.WriteLine "Failed to change key " + strkeypath + " on machine " + Strcomputer
              stdout.WriteLine "error was " + ERROR
              end if


              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) = "Satellite"
              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) & "Error:" & ERR 
              Else
              X=X+1
              end if
              next

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

              Now, were the previous one, if it encountered an error, went back to the main procedure and complained to you, this one will continue on through the loop. It still complains though, and even more loudly!

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

              TheHoFL

                Topic Starter


                Intermediate

                Thanked: 5
                Re: Change screensaver registry remotely...
                « Reply #43 on: June 11, 2009, 05:58:23 PM »
                Hmmm.... now i get the following:

                Quote

                        1 file(s) copied.
                Press any key to continue . . .
                Microsoft (R) Windows Script Host Version 5.7
                Copyright (C) Microsoft Corporation. All rights reserved.

                Connecting to u1jbennett
                Failed to change key .DEFAULT\Control Panel\Desktop on machine u1jbennett
                error was
                Failed to change key S-1-5-19\Control Panel\Desktop on machine u1jbennett
                error was
                Failed to change key S-1-5-19_Classes\Control Panel\Desktop on machine u1jbennet
                t
                error was
                Failed to change key S-1-5-20\Control Panel\Desktop on machine u1jbennett
                error was
                Failed to change key S-1-5-20_Classes\Control Panel\Desktop on machine u1jbennet
                t
                error was
                Failed to change key S-1-5-21-1130582348-1049843267-782984527-50788\Control Pane
                l\Desktop on machine u1jbennett
                error was
                Failed to change key S-1-5-21-1130582348-1049843267-782984527-50788_Classes\Cont
                rol Panel\Desktop on machine u1jbennett
                error was
                Failed to change key S-1-5-18\Control Panel\Desktop on machine u1jbennett
                error was
                Error processing machine, u1jbennettError:438
                Press any key to continue . . .
                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 #44 on: June 11, 2009, 06:01:33 PM »
                hmmm, thats 6 keys that failed- probably all of them.

                Wow, you'd probably have better luck doing this manually!
                I was trying to dereference Null Pointers before it was cool.