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

Author Topic: change my wallpaper each time i login  (Read 8279 times)

0 Members and 1 Guest are viewing this topic.

newkid

    Topic Starter


    Greenhorn

    change my wallpaper each time i login
    « on: July 21, 2010, 02:08:11 AM »
    Hello,

    I want to cycle thru a list of pictures in a directory and update my wallpaper each time i logon to windows

    any ideas on the code I would need...then I assume I put this code in the startup

    Thanks
    Steve

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: change my wallpaper each time i login
    « Reply #1 on: July 21, 2010, 06:12:49 PM »
    I found this in the snippet closet which may help:

    Code: [Select]
    Const HKEY_CURRENT_USER = &H80000001

    strComputer = "."

    intLowNumber = 1
    intHighNumber = 3      'Total Number Of Wallpaper Choices
    intNumber = Int((intHighNumber - intLowNumber + 1) * Rnd + intLowNumber)

    Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

    Select Case intNumber    'Case Statements LowNumber to HighNumber
    Case 1 : strPicture = "fully qualified path to picture 1"
    Case 2 : strPicture = "fully qualified path to picture 2"
    Case 3 : strPicture = "fully qualified path to picture 3"
    End Select

    strKeyPath = "Control Panel\Desktop"
    ValueName = "Wallpaper"

    objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, ValueName, strPicture

    Set intHighNumber to the number of pictures you cycle through. The case statements are sequential from intLowNumber (which should be one) to intHighNumber. Set strPicture to the fully qualified path to each of your pictures.

    The script will randomly select a picture each time it is run and update the registry. If you have a shutdown script, I would put it in there so the wallpaper resets at the next boot. If you put it in the startup folder, the wallpaper change may not take effect until you logoff/logon. You may have to play around with this.

    Save the file with a VBS extension and run from within another script or from the command prompt as cscript scriptname.vbs

    Good luck. 8)
    « Last Edit: July 21, 2010, 06:24:01 PM by Sidewinder »
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein

    newkid

      Topic Starter


      Greenhorn

      Re: change my wallpaper each time i login
      « Reply #2 on: July 22, 2010, 05:46:30 AM »
      thanks for that 

      what about if i wanted to do it in DOS

      for example

      get the oldest file in a directory
      copy it to a target file that is being used for the wallpaper
      change the source file so it becomes the newest file

      cheers

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: change my wallpaper each time i login
      « Reply #3 on: July 22, 2010, 07:47:02 AM »
      First a correction. The VBScript has a missing statement. The corrected version is below:

      Code: [Select]
      Const HKEY_CURRENT_USER = &H80000001

      strComputer = "."

      intLowNumber = 1
      intHighNumber = 3      'Total Number Of Wallpaper Choices

      Randomize
      intNumber = Int((intHighNumber - intLowNumber + 1) * Rnd + intLowNumber)

      Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

      Select Case intNumber    'Case Statements LowNumber to HighNumber
      Case 1 : strPicture = ""
      Case 2 : strPicture = ""
      Case 3 : strPicture = ""
      End Select

      strKeyPath = "Control Panel\Desktop"
      ValueName = "Wallpaper"

      objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, ValueName, strPicture

      Sorry for any confusion.

      Quote
      what about if i wanted to do it in DOS

      First you would need a machine with DOS installed. Why do you want to use batch code anyway on a WinXP machine?

      Code: [Select]
      @echo off

      set source="source directory goes here"
      set dest="destination directory goes here"

      for /f "tokens=* delims=" %%i in ('dir /ta /b /o:d %source%') do (
        echo y | copy "%source%\%%i" "%dest%" > nul
        echo Y | copy /b "%dest%\%%i" "%source%" > nul
        echo y | reg add "HKCU\Control Panel\Desktop" /v Wallpaper /d "%dest%\%%i" > nul 
        goto :eof
      )

      Be sure to change source and dest to valid directory names otherwise its the same stuff as yesterday: The script will select a picture each time it is run and update the registry. If you have a shutdown script, I would put it in there so the wallpaper resets at the next boot. If you put it in the startup folder, the wallpaper change may not take effect until you logoff/logon. You may have to play around with this.

       8)
      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      newkid

        Topic Starter


        Greenhorn

        Re: change my wallpaper each time i login
        « Reply #4 on: July 23, 2010, 04:56:36 AM »
        hello,

        Im a former Cobol programmer, so im learning as i go  :).....so I dont have VB to develop in but I do know a little about dos...not much as you can see

        if there is a way to develop in VB without having to pay for it ....i could do that ??

        I tried the dos script but it gave me this

        Source = "C:\path\input"
        Dest = "C:\path\output"
        copy ""C:\path\input"\pic1.jpg"  ""C:\path\output""

        and the copy didnt work

        thanks for your help

        cheers



        gpl



          Apprentice
        • Thanked: 27
          Re: change my wallpaper each time i login
          « Reply #5 on: July 23, 2010, 05:20:37 AM »
          Check out Microsofts Express range
          http://www.microsoft.com/express/Windows/
          Graham

          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 my wallpaper each time i login
          « Reply #6 on: July 23, 2010, 06:26:00 AM »
          Im a former Cobol programmer

          You might like COBOL.NET  :)
          I was trying to dereference Null Pointers before it was cool.

          Sidewinder



            Guru

            Thanked: 139
          • Experience: Familiar
          • OS: Windows 10
          Re: change my wallpaper each time i login
          « Reply #7 on: July 23, 2010, 07:28:35 AM »
          I guess I got a little carried away with the quotes.

          Code: [Select]
          @echo off

          set source=source directory goes here
          set dest=destination directory goes here

          for /f "tokens=* delims=" %%i in ('dir /a:-d /ta /b /o:d "%source%"') do (
            echo y | copy "%source%\%%i" "%dest%" > nul
            echo Y | copy /b "%dest%\%%i" "%source%" > nul
            echo y | reg add "HKCU\Control Panel\Desktop" /v Wallpaper /d "%dest%\%%i" > nul 
            goto :eof
          )

          Do not quote the source or dest values at the beginning of the code even if the paths have embedded spaces. They will be inserted at the proper time.

          For the record, the first script I posted was VBScript which was installed on your system with Windows. All you need now is a dollar and a dream. ;D 

          There is a compiled help file for VBScript (script56.chm) which you can search for on your machine or you can download it from here

          Except for REXX, IMO VBScript is one of the easiest script languages to learn and has much more functionality than batch code could ever hope to have.

          Good luck.  8)
          The true sign of intelligence is not knowledge but imagination.

          -- Albert Einstein

          newkid

            Topic Starter


            Greenhorn

            Re: change my wallpaper each time i login
            « Reply #8 on: July 25, 2010, 05:17:48 AM »
            It works ...thanks very much !! :D

            Riis

            • Guest
            Re: change my wallpaper each time i login
            « Reply #9 on: January 08, 2011, 12:48:20 PM »
            Hello,
            As I looked for the same (i.e. a small script or tool to change the Windows wallpaper in a random way every day - and without downloading an .exe file...), I tried the VB script available at the URL: http://sites.google.com/site/sharerandomwallpapers/
            It works fine and handles a variable number of files (the VB script listed above only handles 3 files or a constant number of files...).
            I hope it will bring some help! :)
            John