powershell script at first logon

Discussion in 'Scripting' started by stayboogy, Jan 13, 2019.

  1. stayboogy

    stayboogy MDL Addicted

    May 1, 2011
    846
    215
    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
     
  2. stayboogy

    stayboogy MDL Addicted

    May 1, 2011
    846
    215
    30
    #2 stayboogy, Jan 14, 2019
    Last edited: Jan 14, 2019
    (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.
     
  3. yarr1

    yarr1 MDL Novice

    Aug 13, 2017
    2
    1
    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?
     
  4. stayboogy

    stayboogy MDL Addicted

    May 1, 2011
    846
    215
    30
    i'm just using the vbs script to both run the install.cmd and run the command that changes the wallpaper. this gets both things working.
     
  5. stayboogy

    stayboogy MDL Addicted

    May 1, 2011
    846
    215
    30
    if you look in the github, there is a install.reg file, i import this into my install.wim registry so that it runs this package automatically. otherwise, i can just double-click install.vbs.

    the install.vbs only activates the install.cmd and now changes the wallpaper. before it just called the install.cmd, which was done for a reason in the past that i no longer needed, but since it corrects the wallpaper issue the method is left.

    so it goes--apply install.wim, bcdboot my boot drive, copy over my install package to the systemdrive (could be offline added to .wim which is usually what i do if i use the same image a lot), and reboot. first full boot goes directly to the administrator desktop, registry autorun calls the C:\install\install.vbs which then changes wallpaper and runs the full install.cmd.

    as soon as i learn more registry keys for the things i change in control panel after this runs the package will complete.