<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Indented! &#187; group policy</title>
	<atom:link href="http://www.indented.co.uk/index.php/tag/group-policy/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.indented.co.uk</link>
	<description></description>
	<lastBuildDate>Fri, 02 Jul 2010 10:45:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Setting desktop wallpaper</title>
		<link>http://www.indented.co.uk/index.php/2008/12/23/setting-desktop-wallpaper/</link>
		<comments>http://www.indented.co.uk/index.php/2008/12/23/setting-desktop-wallpaper/#comments</comments>
		<pubDate>Tue, 23 Dec 2008 13:27:50 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[VbScript]]></category>
		<category><![CDATA[group policy]]></category>
		<category><![CDATA[vbs]]></category>

		<guid isPermaLink="false">http://www.highorbit.co.uk/?p=671</guid>
		<description><![CDATA[Group Policy will, by default, only set the desktop wallpaper using Active Desktop. It is also possible to set the wallpaper using the logon script, or using a custom Group Policy template. Custom Group Policy Template The first thing to note about the custom policy is that it is an Unmanaged Policy. That means that [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Group Policy will, by default, only set the desktop wallpaper using Active Desktop. It is also possible to set the wallpaper using the logon script, or using a custom Group Policy template.<br />
<span id="more-671"></span></p>
<h3>Custom Group Policy Template</h3>
<p>The first thing to note about the custom policy is that it is an Unmanaged Policy. That means that any setting change will not revert if the policy is set to Disabled or Not Configured. The setting would have to be manually reversed or removed.</p>
<p>The second thing to note is that Unmanaged Policies are not displayed by default. After adding this template select the Administrative Templates folder under User Configuration, then View and Filtering. Remove the tick from &#8220;Show only policy settings that can be fully managed&#8221;. The policy will appear with a red icon instead of the regular blue icon.</p>
<p>This is a template that can be used to set the wallpaper on a client. It must be saved as a Administrative Template (.adm) file and manually added into a policy.</p>
<pre class="brush: plain;">
CLASS USER

CATEGORY &quot;Desktop&quot;
  CATEGORY &quot;Custom Policies&quot;

    KEYNAME &quot;Control Panel\Desktop&quot;

    POLICY &quot;Desktop Wallpaper&quot;

      EXPLAIN !!ExplainText

      PART !!WallpaperPathText EDITTEXT REQUIRED
        VALUENAME &quot;Wallpaper&quot;
      END PART

      PART !!WallpaperStyleText DROPDOWNLIST
        VALUENAME &quot;WallpaperStyle&quot;

        ITEMLIST
          NAME &quot;Centre&quot; VALUE NUMERIC 0 DEFAULT
          NAME &quot;Stretch&quot; VALUE NUMERIC 2
        END ITEMLIST
      END PART

      PART !!TileWallpaperText DROPDOWNLIST
        VALUENAME &quot;TileWallpaper&quot;

        ITEMLIST
          NAME &quot;No&quot; VALUE NUMERIC 0 DEFAULT
          NAME &quot;Yes&quot; VALUE NUMERIC 1
        END ITEMLIST
      END PART

    END POLICY

  END CATEGORY
END CATEGORY

[Strings]
ExplainText=&quot;Specifies the desktop background (wallpaper) displayed on all users' desktops.\n\nThe wallpaper image must be in bitmap (bmp) format.\n\nTo use this setting, type the fully qualified path and name of the file that stores the wallpaper image. You can type a local path, such as C:\Windows\web\wallpaper\home.bmp or a UNC path, such as \\Server\Share\Corp.bmp. If the specified file is not available when the user logs on, no wallpaper is displayed. You can also use this setting to specify that the wallpaper image be centered, tiled, or stretched.\n\nTo set wallpaper to Centre Tile must be disabled. To set wallpaper to Tiled both Centre and Tiled must be selected.&quot;
WallpaperPathText=&quot;Full UNC or path to Bitmap (bmp) file:&quot;
WallpaperStyleText=&quot;Centre or Stretch Wallpaper:&quot;
TileWallpaperText=&quot;Tile Wallpaper (if centre is selected):&quot;
</pre>
<h3>VbScript</h3>
<p>Alternatively, the same registry entries can be set using VbScript. This has the potential to be more flexible depending on the environment. It will run under a standard user, no need to grant extra rights on the PC.</p>
<pre class="brush: vb;">
Option Explicit

' Network and local locations for the wallpaper file.
' Must be BMP for the screen refresh to work
Const WALLPAPER_SOURCE = &quot;\\server01\netlogon\Wallpaper.bmp&quot;

Sub SetWallpaper
  ' Copies and sets the client wallpaper

  Const REG_HKCU = &amp;H80000001

  Dim objShell, objFileSystem, objFile, objRegistry
  Dim strWallpaperDestination, strKeyPath, strCommand

  ' Get the current user profile so we can copy the wallpaper there.
  Set objShell = CreateObject(&quot;WScript.Shell&quot;)
  strWallpaperDestination = objShell.ExpandEnvironmentStrings(&quot;%USERPROFILE%&quot;)

  ' Get the wallpaper file from the source
  Set objFileSystem = CreateObject(&quot;Scripting.FileSystemObject&quot;)
  Set objFile = objFileSystem.GetFile(WALLPAPER_SOURCE)

  ' Update the destination path to include the file name
  strWallpaperDestination = strWallpaperDestination &amp; &quot;\&quot; &amp; objFile.Name
  objFile.Copy strWallpaperDestination, True
  Set objFileSystem = Nothing

  ' Connect to the Registry on the local machine
  Set objRegistry = GetObject(&quot;winmgmts:\\.\root\default:StdRegProv&quot;)

  ' Set the values for the Wallpaper
  strKeyPath = &quot;Control Panel\Desktop&quot;
  objRegistry.SetStringValue REG_HKCU, strKeyPath, &quot;Wallpaper&quot;, _
    strWallpaperDestination

  ' Set the Position to Stretch
  objRegistry.SetStringValue REG_HKCU, strKeyPath, &quot;TileWallpaper&quot;, &quot;0&quot;
  objRegistry.SetStringValue REG_HKCU, strKeyPath, &quot;WallpaperStyle&quot;, &quot;2&quot;
  Set objRegistry = Nothing

  ' Update the system settings (refresh)
  strCommand = &quot;RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters&quot;
  objShell.Run strCommand, 1, True
  Set objShell = Nothing
End Sub

SetWallpaper
</pre>
<h3>Random wallpaper with VbScript</h3>
<p>I once had to deploy one of a selection of wallpapers to client computers on a network. It had to change (or at least attempt to change) each time the user logged on. This snippet uses the Randomize function in VbScript to generate a random number and pick a random file.</p>
<pre class="brush: vb;">
Option Explicit

Sub SetWallpaper
  ' Copies and sets the client wallpaper

  Const REG_HKCU = &amp;H80000001

  Dim objShell, objFileSystem, objFile, objRegistry
  Dim strWallpaperSource, strWallpaperDestination, strKeyPath, strCommand

  ' Get the current user profile so we can copy the wallpaper there.
  Set objShell = CreateObject(&quot;WScript.Shell&quot;)
  strWallpaperDestination = objShell.ExpandEnvironmentStrings(&quot;%USERPROFILE%&quot;)

  ' Get the source path
  strWallpaperSource = RandomizeWallpaper

  ' Get the wallpaper file from the source
  Set objFileSystem = CreateObject(&quot;Scripting.FileSystemObject&quot;)
  Set objFile = objFileSystem.GetFile(strWallpaperSource)

  ' Update the destination path to include the file name
  strWallpaperDestination = strWallpaperDestination &amp; &quot;\&quot; &amp; objFile.Name
  objFile.Copy strWallpaperDestination, True
  Set objFileSystem = Nothing

  ' Connect to the Registry on the local machine
  Set objRegistry = GetObject(&quot;winmgmts:\\.\root\default:StdRegProv&quot;)

  ' Set the values for the Wallpaper
  strKeyPath = &quot;Control Panel\Desktop&quot;
  objRegistry.SetStringValue REG_HKCU, strKeyPath, &quot;Wallpaper&quot;, strWallpaperDestination

  ' Set the Position to Stretch
  objRegistry.SetStringValue REG_HKCU, strKeyPath, &quot;TileWallpaper&quot;, &quot;0&quot;
  objRegistry.SetStringValue REG_HKCU, strKeyPath, &quot;WallpaperStyle&quot;, &quot;2&quot;
  Set objRegistry = Nothing

  ' Update the system settings (refresh)
  strCommand = &quot;RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters&quot;
  objShell.Run strCommand, 1, True
  Set objShell = Nothing
End Sub

Function RandomizeWallpaper
  Dim objShell, objFolder, objSubFolder, objFile
  Dim  strLogonServer
  Dim arrWallpaper()
  Dim i

  ' Get the current user profile so we can copy the wallpaper there.
  Set objShell = CreateObject(&quot;WScript.Shell&quot;)
  strLogonServer = objShell.ExpandEnvironmentStrings(&quot;%LOGONSERVER%&quot;)
  Set objShell = Nothing

  Set objFolder = objFileSystem.GetFolder(strLogonServer &amp; &quot;\NetLogon\Wallpaper&quot;)
  i = 0

  ' Get all the files beneath the folder
  For Each objFile in objFolder.Files
    ReDim Preserve arrWallpaper(i)
    arrWallpaper(i) = objFile.Path
    i = i + 1
  Next
  Randomize()

  ' Choose a random file
  i = Int(UBound(arrWallpaper) * Rnd())
  RandomizeWallpaper = arrWallpaper(i)
End Function

SetWallpaper
</pre>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.indented.co.uk/index.php/2008/12/23/setting-desktop-wallpaper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
