Bat file for Group policy

imhotep

Well-known member
  • Mar 29, 2017
    14,824
    8
    35,334
    113
    In a Domain setup you can use the Group Policy Management Console and create a GPO.

    On workstation basis you should be able to write a powershell script or even a .bat file with commands to set the registry keys & then use Rundll32.exe
     
    • Like
    Reactions: Aruna119

    PickelRick

    Active member
  • Apr 25, 2020
    194
    157
    43
    In a Domain setup you can use the Group Policy Management Console and create a GPO.

    On workstation basis you should be able to write a powershell script or even a .bat file with commands to set the registry keys & then use Rundll32.exe
    Any source that I can refer
     

    imhotep

    Well-known member
  • Mar 29, 2017
    14,824
    8
    35,334
    113
    GPO walin puluwan
    Yes quite easy with a GPO specially when you are in a domain.
    Open Group Policy Management Console.
    Right click on the domain and click Create a GPO in this domain and link it here.
    Just name the GPO, once the GPO is created, right click and select Edit. Group Policy Management Editor will open
    User Configuration, expand Administrative Templates, expand Desktop, and then click Desktop. In the details pane, double-click Desktop Wallpaper.
    Select Enabled and fill up the other boxes and Apply.
     

    imhotep

    Well-known member
  • Mar 29, 2017
    14,824
    8
    35,334
    113
    Tfs this really helps

    GPO walin lesi thama
    But I need to do the whole process just using one click (by running the powershell script):p

    This should work too.....in a batch file.
    @echo off
    reg add "HKCU\control panel\desktop" /v wallpaper /t REG_SZ /d "" /f
    reg add "HKCU\control panel\desktop" /v wallpaper /t REG_SZ /d "C:\[LOCATION OF WALLPAPER HERE]" /f
    reg delete "HKCU\Software\Microsoft\Internet Explorer\Desktop\General" /v WallpaperStyle /f
    reg add "HKCU\control panel\desktop" /v WallpaperStyle /t REG_SZ /d 2 /f
    RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters
    exit

    Note: Once you set the registry then only needs to run the last line.
     

    PickelRick

    Active member
  • Apr 25, 2020
    194
    157
    43
    This should work too.....in a batch file.
    @echo off
    reg add "HKCU\control panel\desktop" /v wallpaper /t REG_SZ /d "" /f
    reg add "HKCU\control panel\desktop" /v wallpaper /t REG_SZ /d "C:\[LOCATION OF WALLPAPER HERE]" /f
    reg delete "HKCU\Software\Microsoft\Internet Explorer\Desktop\General" /v WallpaperStyle /f
    reg add "HKCU\control panel\desktop" /v WallpaperStyle /t REG_SZ /d 2 /f
    RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters
    exit

    Note: Once you set the registry then only needs to run the last line.
    This is working fine...
    is this your own code?
    also I want run this command in a remote PC so that do you think if I add the below code. it will work fine

    $credential = Get-Credential -Credential nwtraders\administrator