powershell script at first logon

Discussion in 'Scripting' started by stayboogy, Jan 13, 2019 at 23:57.

  1. stayboogy

    stayboogy MDL Addicted

    May 1, 2011
    720
    116
    30
    so i run an install.cmd at first boot after the oobe, after i apply my windows images.

    one of things this does is set the user wallpaper. i do this with a powershell script:

    Code:
    Function Set-WallPaper($Value)
    {
    Set-ItemProperty -path 'HKCU:\Control Panel\Desktop\' -name wallpaper -value "$value"
    rundll32.exe user32.dll, UpdatePerUserSystemParameters
    }
    
    Set-WallPaper -Value "C:\install\wallpaper\wallpaper.jpg"
    i can either run this by executing
    Code:
     powershell.exe -NoProfile -ExecutionPolicy Bypass -File C:\Install\wallpaper\wallpaper.ps1
    from the command line

    or pasting that into wallpaper.cmd and running it by double-clicking.

    both those methods work fine and change the wallpaper the first time.

    however, if i want to either a) run the command in my install.cmd it completes without failure but doesn't actually change the wallpaper or b) i can "start" or "call" wallpaper.cmd from my install.cmd which completes but never changes the wallpaper.

    i can open another cmd and run the command in full or start or call the wallpaper.cmd and all works well, but it NEVER WORKS when called from install.cmd.

    HOW TO GET THIS WORKING from install.cmd???

    you can see the whole package here (look in SYSTEMDRIVE\install):
    https://github.com/stayboogy/WindowsUnattendPostSetup
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. stayboogy

    stayboogy MDL Addicted

    May 1, 2011
    720
    116
    30
    #2 stayboogy, Jan 14, 2019 at 00:22
    Last edited: Jan 14, 2019 at 00:38
    (OP)
    nevermind i guess... i still do not know why it will not work, but, if i add the straight powershell command line to my install.vbs it works perfectly so i'll just bypass install.cmd method.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. yarr1

    yarr1 MDL Novice

    Aug 13, 2017
    1
    0
    0
    as someone trying to learn more about unattended setups and windows scripts I got to say this stuff is so impressive. are you saying not to use the command but the vbs then?