Hi,
first post here (and just tipping my toe into the Powershell waters!)
basically I'm trying to get a script that will update the wallpaper on my desktop - ideally I'd like to specify a folder and the script to change the wallpaper to one of the images in the folder for say 5 secs then update again. Kinda like a screen saver but using the wallpaper feature.
This is just for fun - I thought I'd use this idea as a vehicle to play around with powershell.
So far have found the IActiveDesktop COM interface which appears as if it might do the job but can't work out how to use this in a powershell script. I've also found out about the WMI class Win32_Desktop (from memory I think it was called that) but the wallpaper property appears to be read-only.
Sorry if this is a bit vague but it's my first day back at work after a two week break and my brain is not fully functional yet!
Any help much appreciated.
jack craig
How do I get a Powershell script to set Wallpaper?
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
How do I get a Powershell script to set Wallpaper?
Hi,
first post here (and just tipping my toe into the Powershell waters!)
basically I'm trying to get a script that will update the wallpaper on my desktop - ideally I'd like to specify a folder and the script to change the wallpaper to one of the images in the folder for say 5 secs then update again. Kinda like a screen saver but using the wallpaper feature.
This is just for fun - I thought I'd use this idea as a vehicle to play around with powershell.
So far have found the IActiveDesktop COM interface which appears as if it might do the job but can't work out how to use this in a powershell script. I've also found out about the WMI class Win32_Desktop (from memory I think it was called that) but the wallpaper property appears to be read-only.
Sorry if this is a bit vague but it's my first day back at work after a two week break and my brain is not fully functional yet!
Any help much appreciated.
jack craig
first post here (and just tipping my toe into the Powershell waters!)
basically I'm trying to get a script that will update the wallpaper on my desktop - ideally I'd like to specify a folder and the script to change the wallpaper to one of the images in the folder for say 5 secs then update again. Kinda like a screen saver but using the wallpaper feature.
This is just for fun - I thought I'd use this idea as a vehicle to play around with powershell.
So far have found the IActiveDesktop COM interface which appears as if it might do the job but can't work out how to use this in a powershell script. I've also found out about the WMI class Win32_Desktop (from memory I think it was called that) but the wallpaper property appears to be read-only.
Sorry if this is a bit vague but it's my first day back at work after a two week break and my brain is not fully functional yet!
Any help much appreciated.
jack craig
How do I get a Powershell script to set Wallpaper?
This sets thet wallpaper value:
Code: Select all
set-itemproperty -path "HKCU:Control PanelDesktop" -name WallPaper -value Zapotec.bmp
How do I get a Powershell script to set Wallpaper?
thanks jvierra for the SetWallpaper.txt, I will try that tonight - yep powershell does seem fun, seems a lot more powerfull and intuitive than anything else I've used to date...
How do I get a Powershell script to set Wallpaper?
It is teh "cat's pajamas" of scripting in teh Windows World. I understand that Apple and Unix are negotiating for license rights. The full movie should be coming out in June. Stay tuned.
I left the timeout as an excercise for you. The method is not really related to Powerhell but is a technique that is around for vbscript and command files so I just wrapped them to kinda show how neat PowerShell can be.
I left the timeout as an excercise for you. The method is not really related to Powerhell but is a technique that is around for vbscript and command files so I just wrapped them to kinda show how neat PowerShell can be.
How do I get a Powershell script to set Wallpaper?
uploads/27955/wallpaper.txt
I've made two changes to the code example in the file helpfully posted by jvierra - I changed the use of $file.Name to $file.FullName and also modified the key "Wallpaper" in HKCU:SoftwareMicrosoftInternet ExplorerDesktopGeneral (Not sure if that bit was necessary)
Anyway it works and its all good fun!
One thing I'm going to look at is if I can restrict the area that gets redrawn as currently the desktop icons I have get redrawn even though they don't overlap the images I'm using (the images are only about 1000x750 pixels set on a black background). I'll post anything I find out on this.
Thanks again for the headstart jvierra
I've made two changes to the code example in the file helpfully posted by jvierra - I changed the use of $file.Name to $file.FullName and also modified the key "Wallpaper" in HKCU:SoftwareMicrosoftInternet ExplorerDesktopGeneral (Not sure if that bit was necessary)
Anyway it works and its all good fun!
One thing I'm going to look at is if I can restrict the area that gets redrawn as currently the desktop icons I have get redrawn even though they don't overlap the images I'm using (the images are only about 1000x750 pixels set on a black background). I'll post anything I find out on this.
Thanks again for the headstart jvierra
How do I get a Powershell script to set Wallpaper?
Here's my contribution to the cause:
Code: Select all
function set-wallpaper{
Param ( [string]$newpaper="",[string]$format)
switch ($format) {
"tiled" {$tile=1;$style=0}
"centered" {$tile=0;$style=0}
"fit" {$tile=0;$style=2}
default {$tile=0;$style=0}
}
#verify file exists
if (Get-ChildItem $newpaper -ea "SilentlyContinue") {
$regkeys="HKCU:Control PanelDesktop","HKCU:SoftwareMicrosoftInternet ExplorerDesktopGeneral"
foreach ($regkey in $regkeys) {
Set-ItemProperty -path $regkey -name WallPaper -value $newpaper
Set-ItemProperty -path $regkey -name TileWallpaper -value $tile
Set-ItemProperty -path $regkey -name WallpaperStyle -value $style
}
$rundll32="{0}System32RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters" -f $env:windir
Invoke-Expression -Command $rundll32
}
else {
Write-Warning "Failed to find $newpaper"
}
}
How do I get a Powershell script to set Wallpaper?
And this way you can automatically change the wallpaper.. I was thinking about running the script after start of windows
martyix2008-09-05 06:50:48
Code: Select all
function set-wallpaper([string]$newpaper="", [string]$format){
echo "test"
switch ($format) {
"tiled" {$tile=1;$style=0}
"centered" {$tile=0;$style=0}
"fit" {$tile=0;$style=2}
default {$tile=0;$style=0}
}
#verify file exists
if (Get-ChildItem $newpaper -ea "SilentlyContinue") {
$regkeys="HKCU:Control PanelDesktop","HKCU:SoftwareMicrosoftInternet ExplorerDesktopGeneral"
foreach ($regkey in $regkeys) {
Set-ItemProperty -path $regkey -name WallPaper -value $newpaper
Set-ItemProperty -path $regkey -name TileWallpaper -value $tile
Set-ItemProperty -path $regkey -name WallpaperStyle -value $style
}
$rundll32="{0}System32RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters" -f $env:windir
Invoke-Expression -Command $rundll32
}
else {
Write-Warning "Failed to find $newpaper"
}
}
$folder="D:FunFrancie2008"
$file=get-Childitem $folder -name | get-Random
set-wallpaper $folder/$file "fit"