Showing posts with label Registry. Show all posts
Showing posts with label Registry. Show all posts

Thursday, August 1, 2013

Set Random Wallpaper on your Desktop using Powershell


Hi,

We all love wallpapers. I and love them too.

Sometime they reflect our moods too. I have a huge collection of Wallpapers and i love to change my wallpapers in once or twice a week.

In the time of windows XP, i used to have a software which changed my wallpaper daily when i login to the laptop.

To be frank i never used to have a any desktop changer software in my windows7 laptop.

Few days ago i just write a small snippet code to change my wallpaper on daily basis.

How i do that ,

It is simple, Powershell + Registry and that all.

Download Link : http://gallery.technet.microsoft.com/scriptcenter/Set-Random-Wallpaper-Using-e79e423

Lets do it.

The below variable is storing the path to my Pictures. {you can change it to with yours ,, or you can use Join-Path $env:USERPROFILE  -ChildPath Pictures .}

$myPictureFolder = 'C:\Users\aman.dhally\Pictures\’

Now, i am running Get-ChildItem (dir) on our Picture folder, and using Get-Random cmdlet, i am choosing any single  wallpaper randomly.

$getRandomWallpaper = Get-ChildItem -Recurse $myPictureFolder |where {$_.Extension -eq ".jpg"}  | Get-Random -Count 1

Now we are using Set-ItemProperty to set the select wallpaper to the desktop.
To update the desktop we have to use rundll32.exe and to be frank, until we don’t run the  "

rundll32.exe user32.dll, UpdatePerUserSystemParameters

” code 3-4 time wallpaper wont change. or we reboot the laptop.

Set-ItemProperty -path 'HKCU:\Control Panel\Desktop\' -name wallpaper -value $getRandomWallpaper.FullName 
rundll32.exe user32.dll, UpdatePerUserSystemParameters
Completer Script
$myPictureFolder = 'C:\Users\AD\Pictures\WallPapers\IronMan'

# $myPictureFolder = Join-Path $env:USERPROFILE  -ChildPath Pictures
$getRandomWallpaper = Get-ChildItem -Recurse $myPictureFolder |where {$_.Extension -eq ".jpg"}  | Get-Random -Count 1
Set-ItemProperty -path 'HKCU:\Control Panel\Desktop\' -name wallpaper -value $getRandomWallpaper.FullName 

rundll32.exe user32.dll, UpdatePerUserSystemParameters  
rundll32.exe user32.dll, UpdatePerUserSystemParameters
rundll32.exe user32.dll, UpdatePerUserSystemParameters

Download Linkhttp://gallery.technet.microsoft.com/scriptcenter/Set-Random-Wallpaper-Using-e79e423


Note: I tested this on windows 7 32 bit only.
Thanks
Aman Dhally
clip_image001 clip_image002 clip_image003 clip_image005clip_image007

Wednesday, July 24, 2013

Changing Desktop Wallpaper Positions using Powershell.

 

Hi,

Yesterday i blogged about changing Desktop background colour using Powershell.

Today we are going to change the Desktop Wallpaper Position using Powershell. Like the previous post this is again a registry tweak.

Windows Desktop wallpaper has 5 types of  Picture Position.

  1. Center
  2. Fill
  3. Fit
  4. Stretch
  5. Tile

The registry key which retains these settings is HKey_Current_User\Control Panel\Desktop and the registry key name is “WallpaperStyle

 

Setting “WallpaperStyle” reg key value
Center 0
Fit 6
Fill 10
Stretch 2
Tile 0

Lets try it :)

24-07-2013 19-13-17

I have  centrally positioned wallpaper of my daughter “Manya”  and lets changed the position to FIT one.

Set-ItemProperty 'HKCU:\Control Panel\Desktop' -Name "WallpaperStyle" -Value 6

24-07-2013 19-15-09

now log off and log-in again.

and here you go , the “Picture Position” is set to “Fit.”

24-07-2013 19-16-54

Now lets set the wallpaper position to “Fill”

Here is our code, run it,

Set-ItemProperty 'HKCU:\Control Panel\Desktop' -Name "WallpaperStyle" -Value 10

24-07-2013 19-18-00

log-off and re login again. and our “Picture Position is set to fill :)

24-07-2013 19-18-49

Now, lets set it to the “Stretch”

run the code

Set-ItemProperty 'HKCU:\Control Panel\Desktop' -Name "WallpaperStyle" -Value 2

24-07-2013 19-19-46

log-off and re-login again , and the wallpaper is set to “Stretch” now.

24-07-2013 19-20-30

if you want to set wallpaper as TILE then we have to tweak two keys. the WallpaperStyle" and “TileWallpaper"

To tile the wallpaper, we need to set “TileWallpaper" to 1

run the script code.

Set-ItemProperty 'HKCU:\Control Panel\Desktop' -Name "WallpaperStyle" -Value 0

Set-ItemProperty 'HKCU:\Control Panel\Desktop' -Name "TileWallpaper" -Value 1

24-07-2013 19-23-24 

Log-off and log-in again.

and i can see my cute bunny’s picture all over the monitor.. :) . It successfully positioned as tile.

24-07-2013 19-24-45

Okies. now lets set every thing back to normal.

I am setting wallpaper as “cantered” positioned  and tile key to off.

Set-ItemProperty 'HKCU:\Control Panel\Desktop' -Name "WallpaperStyle" -Value 0

Set-ItemProperty 'HKCU:\Control Panel\Desktop' -Name "TileWallpaper" -Value 0

24-07-2013 19-25-30

log-off and log-in again.

and you can see, there is no tile and wallpaper is centrally positioned.

24-07-2013 19-27-09

I hope that you will find it handy and helpful.

Thanks
Aman Dhally
 
 
clip_image001 clip_image002 clip_image003 clip_image005clip_image007

Friday, August 31, 2012

Setting Microsoft Office 2012 Trust Center's Trusted Location Paths using Powershell.

Hi Everyone.

If you are working in a Telecom Industry, and if your Analysts and Consultants are using in house built templates then i am sure that you are 98% facing the “Trust Centre warning”.

We are using custom in house built Office Templates for Word,Excel, and PowerPoint.  and the problem was whenever we open our in house templates is Office 2012 we were facing the below error.

We can click on it but it is a quite annoying.

31-08-2012 14-47-12

To resolved this error, the solution is to add our custom built templates directory to the  trusted location in trust center manually on every laptop and desktop.

31-08-2012 15-14-10

Did i mentioned MANUALLY???

Naaaaaa !!!!!!! I thought that we can script this.

And to resolve this is wrote a simple script. you can download the script from this link :
http://gallery.technet.microsoft.com/scriptcenter/Setting-office-2010-31d6a5f4

This script is very simple.,

You only need to provide the path of your templates or the location which you want to add as trusted to  $trustlocation variable.
$trustlocation = 'C:\Mylocation\Templates'
and that’s all , when you run the script , the script will create a location registry  named as “Location99” in to the registry.
and the Registry Keys will be look like this .
31-08-2012 15-33-48
and i have added comments in the script for easy understanding,
Functionality.
  1. First script test the path of the “Location99” registry key
  2. and if the Test path fails that will create a New Registry  Folder “Location99” and the the following registry keys
      • AllowSubfolders this is DWORD registry key and the value is 1 to allow subfolders as a trusted location too.
      • Date  = Date of creation
      • Description = Description for location etc.
      • Path  =  Path to the folder
  3. and if folder found it just write a confirmation message in the console that folder do exists.
  4. The script will do the same process for WORD,EXCEL and Powerpoint.
After running the script the location is added to the Word.
31-08-2012 15-15-24

Thanks
Aman Dhally
join aman on facebook Join aman on Linkedin follow aman on Twitter

Tuesday, December 13, 2011

How to List Registry Hives

 

PowerTip of the Day, from PowerShell.com:

Use the provider name instead of a drive name when you need to get a list of all Registry Hives:

Dir Registry::

thanks

aman