script to change logon wallpaper on windows XP and 7 ...
-
Wednesday, June 09, 2010 12:53 AM
Hi there,
We have both windows XP and windows 7 in our organization and just wondering how to change the logon wallpaper via script.
We're in a subdomain of a larger network and they haven't made a move to Server 2008 ... so group policy is not possible.what we need is a script to auto-detect whether it's a windows XP or 7, then apply the necessary registry settings.
I found the way to run a script / modify registry settings to change the logon wallpaper by modifying the registry settings manually and then export it to a network location (edit it as necessary), and then run the script --> regedit.exe /s filename.reg
- Windows XP
http://www.tweaklibrary.com/System/Startup-and-Shutdown/60/Set-the-log-on-tile-screen-wallpaper/10626/- Windows 7
http://www.techspot.com/guides/224-change-logon-screen-windows7/We can't apply both settings at the same time since since the regKey is different between xp and 7.
help?
All Replies
-
Wednesday, June 09, 2010 7:32 AMModerator
Hi
Here you go, this should do the trick. Apply this to a computer startup script, it will determine the operating system from the registry then modify the appropriate registry keys. This assumes you've placed the image in:
%windir%\oobe\info\Backgrounds\backgroundDefault.jpg (it must be less than 265KB otherwise it won't work...i tryed)
Cheers Matt :)
'---------------------------------------------------------------------------------------------------------------------------- 'Script Name : SetLogonWallPaper.vbs 'Author : Matthew Beattie 'Created : 09/06/10 'Description : This script sets the Logon WallPaper based on the operating system type. '---------------------------------------------------------------------------------------------------------------------------- 'Initialization Section. Define and Create Global Variables. '---------------------------------------------------------------------------------------------------------------------------- Option Explicit Dim objFSO, wshShell, systemPath, fileSpec On Error Resume Next Set objFSO = CreateObject("Scripting.FileSystemObject") Set wshShell = CreateObject("WScript.Shell") systemPath = wshShell.ExpandEnvironmentStrings("%WinDir%") If Err.Number <> 0 Then WScript.Quit End If On Error Goto 0 '---------------------------------------------------------------------------------------------------------------------------- 'Main Processing Section '---------------------------------------------------------------------------------------------------------------------------- On Error Resume Next ProcessScript If Err.Number <> 0 Then WScript.Quit End If On Error Goto 0 '---------------------------------------------------------------------------------------------------------------------------- 'Name : ProcessScript -> Primary Function that controls all other script processing. 'Parameters : None -> 'Return : None -> '---------------------------------------------------------------------------------------------------------------------------- Function ProcessScript Dim regKey, version, systemType regKey = "HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProductName" version = ReadRegistry(regKey) Select Case version Case "Windows 7 Ultimate" fileSpec = systemPath & "\oobe\Info\Backgrounds\backgroundDefault.jpg" systemType = 0 Case "Microsoft Windows XP" systemType = 1 fileSpec = systemPath & "\Web\Wallpaper\Bliss.bmp" Case Else Exit Function End Select '------------------------------------------------------------------------------------------------------------------------- 'Set the Logon Wallpaper based on the operating system type. '------------------------------------------------------------------------------------------------------------------------- If Not SetLogonWallPaper(systemType) Then Exit Function End If End Function '---------------------------------------------------------------------------------------------------------------------------- 'Name : ReadRegistry -> Read the value of a registry key or value. 'Parameters : key -> Name of the key (ending in "\") or value to read. 'Return : ReadRegistry -> Value of key or value read from the local registry (blank is not found). '---------------------------------------------------------------------------------------------------------------------------- Function ReadRegistry(ByVal key) Dim result If StrComp(Left (key, 4), "HKU\", vbTextCompare) = 0 Then Key = "HKEY_USERS" & Mid(key, 4) End If On Error Resume Next ReadRegistry = WshShell.RegRead (key) If Err.Number <> 0 Then ReadRegistry = "" End If On Error Goto 0 End Function '---------------------------------------------------------------------------------------------------------------------------- 'Name : SetLogonWallPaper -> Sets the Logon Wallpaper registry settings based on the operating system type. 'Parameters : systemType -> Integer identifying the operating system type. 'Return : SetLogonWallPaper -> Returns True if the LogonWallPaper registry settings were updated otherwise False. '---------------------------------------------------------------------------------------------------------------------------- Function SetLogonWallPaper(systemType) Dim elements, element, regKey, regValue, regType SetLogonWallPaper = False '------------------------------------------------------------------------------------------------------------------------- 'Define the registry settings based on the systemType '------------------------------------------------------------------------------------------------------------------------- Select Case systemType Case 0 elements = Array("HKLM\Software\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background\OEMBackground,1,REG_DWORD") Case 1 elements = Array("HKEY_USERS\.Default\Control Panel\Desktop\TileWallpaper,1,REG_SZ", _ "HKEY_USERS\.Default\Control Panel\Desktop\WallpaperStyle,2,REG_SZ", _ "HKEY_USERS\.Default\Control Panel\Desktop\Wallpaper," & fileSpec & ",REG_SZ") Case Else Exit Function End Select '------------------------------------------------------------------------------------------------------------------------- 'Configure the registry settings. '------------------------------------------------------------------------------------------------------------------------- For Each element In elements On Error Resume Next regKey = Split(element, ",")(0) regValue = Split(element, ",")(1) regType = Split(element, ",")(2) MsgBox regKey wshShell.RegWrite regKey, regValue, regType If Err.Number <> 0 Then Exit Function End If On Error Goto 0 Next SetLogonWallPaper = True End Function '----------------------------------------------------------------------------------------------------------------------------- Proposed As Answer by MatthewBeattieModerator Wednesday, June 09, 2010 7:34 AM
- Marked As Answer by IamMredMicrosoft Employee, Owner Friday, June 18, 2010 5:58 AM
-
Wednesday, June 09, 2010 7:34 AMModerator
Hi
Ensure you edit the Select Case statement to reflect the value of the version of Windows 7 you are using:
Select Case version
Case "Windows 7 Ultimate"EG you may need to change this to "Windows 7 Enterprise" etc.
Cheers Matt :)
- Marked As Answer by IamMredMicrosoft Employee, Owner Friday, June 18, 2010 5:58 AM
-
Wednesday, June 09, 2010 11:58 AMModerator
Hey
Here is an updated version, checks if the image file exists rather than assuming it does and removes a the MsgBox i was using for testing. Let me know if you have any trouble with it.
Cheers Matt :)
'---------------------------------------------------------------------------------------------------------------------------- 'Script Name : SetLogonWallPaper.vbs 'Author : Matthew Beattie 'Created : 09/06/10 'Description : This script sets the Logon WallPaper based on the operating system type. '---------------------------------------------------------------------------------------------------------------------------- 'Initialization Section. Define and Create Global Variables. '---------------------------------------------------------------------------------------------------------------------------- Option Explicit Dim objFSO, wshShell, systemPath, fileSpec On Error Resume Next Set objFSO = CreateObject("Scripting.FileSystemObject") Set wshShell = CreateObject("WScript.Shell") systemPath = wshShell.ExpandEnvironmentStrings("%WinDir%") ProcessScript If Err.Number <> 0 Then WScript.Quit End If On Error Goto 0 '---------------------------------------------------------------------------------------------------------------------------- 'Name : ProcessScript -> Primary Function that controls all other script processing. 'Parameters : None -> 'Return : None -> '---------------------------------------------------------------------------------------------------------------------------- Function ProcessScript Dim regKey, version, systemType regKey = "HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProductName" version = ReadRegistry(regKey) '------------------------------------------------------------------------------------------------------------------------- 'Set variable's based on the operating system version that has been read from the registry. '------------------------------------------------------------------------------------------------------------------------- Select Case version Case "Windows 7 Ultimate" systemType = 0 fileSpec = systemPath & "\oobe\Info\Backgrounds\backgroundDefault.jpg" Case "Microsoft Windows XP" systemType = 1 fileSpec = systemPath & "\Web\Wallpaper\Bliss.bmp" Case Else Exit Function End Select '------------------------------------------------------------------------------------------------------------------------- 'Ensure the image file exists before attempting to configure the Logon Wallpaper. '------------------------------------------------------------------------------------------------------------------------- If Not objFSO.FileExists(fileSpec) Then Exit Function End If '------------------------------------------------------------------------------------------------------------------------- 'Set the Logon Wallpaper based on the operating system type. '------------------------------------------------------------------------------------------------------------------------- If Not SetLogonWallPaper(systemType) Then Exit Function End If End Function '---------------------------------------------------------------------------------------------------------------------------- 'Name : ReadRegistry -> Read the value of a registry key or value. 'Parameters : key -> Name of the key (ending in "\") or value to read. 'Return : ReadRegistry -> Value of key or value read from the local registry (blank is not found). '---------------------------------------------------------------------------------------------------------------------------- Function ReadRegistry(ByVal key) Dim result If StrComp(Left(key, 4), "HKU\", vbTextCompare) = 0 Then Key = "HKEY_USERS" & Mid(key, 4) End If On Error Resume Next ReadRegistry = WshShell.RegRead(key) If Err.Number <> 0 Then ReadRegistry = "" End If On Error Goto 0 End Function '---------------------------------------------------------------------------------------------------------------------------- 'Name : SetLogonWallPaper -> Sets the Logon Wallpaper registry settings based on the operating system type. 'Parameters : systemType -> Integer identifying the operating system type. 'Return : SetLogonWallPaper -> Returns True if the LogonWallPaper registry settings were updated otherwise False. '---------------------------------------------------------------------------------------------------------------------------- Function SetLogonWallPaper(systemType) Dim elements, element, regKey, regValue, regType SetLogonWallPaper = False '------------------------------------------------------------------------------------------------------------------------- 'Set the registry settings to configure based on the systemType integer. '------------------------------------------------------------------------------------------------------------------------- Select Case systemType Case 0 elements = Array("HKLM\Software\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background\OEMBackground,1,REG_DWORD") Case 1 elements = Array("HKEY_USERS\.Default\Control Panel\Desktop\TileWallpaper,0,REG_SZ", _ "HKEY_USERS\.Default\Control Panel\Desktop\WallpaperStyle,2,REG_SZ", _ "HKEY_USERS\.Default\Control Panel\Desktop\Wallpaper," & fileSpec & ",REG_SZ") Case Else Exit Function End Select '------------------------------------------------------------------------------------------------------------------------- 'Split the array elements and configure the registry settings. '------------------------------------------------------------------------------------------------------------------------- For Each element In elements On Error Resume Next regKey = Split(element, ",")(0) regValue = Split(element, ",")(1) regType = Split(element, ",")(2) wshShell.RegWrite regKey, regValue, regType If Err.Number <> 0 Then Exit Function End If On Error Goto 0 Next SetLogonWallPaper = True End Function '----------------------------------------------------------------------------------------------------------------------------- Marked As Answer by IamMredMicrosoft Employee, Owner Friday, June 18, 2010 5:58 AM
-
Thursday, February 03, 2011 3:31 PM
Hey Matthew,
What is the location in Server 2008 R2 where the image would go?
-
Friday, February 04, 2011 3:08 AM
sorry ... I didn't realized someone replied to this post.
I ended up found a script that, similar to yours, checking the version of the OS.
Andrew P. -
Tuesday, February 08, 2011 2:36 PMEd, it's the same location in '08R2 - C:\windows\system32\oobe\info\backgrounds
-
Saturday, March 12, 2011 9:32 PM
sorry ... I didn't realized someone replied to this post.
I ended up found a script that, similar to yours, checking the version of the OS.
Andrew P.Hi Andrew, would you mind posting your script as well please?
Thanks.
-
Monday, September 19, 2011 5:21 PM
This doesn't seem to work. My OS is Windows 7 Professional. Changed the script to reflect that and it still doesn't change my login screen. backgroudDefault.jpg is sitting in C:\Windows\System32\oobe\info\backgrounds.
-
Wednesday, September 21, 2011 12:09 AM
ah, again, I apologize.
I knew someone asked for a script but don't remember on which forum.I found a simple script that detects which OS here:
http://malektips.com/xp_dos_0025.htmland modified it as below:
(better to copy paste it somewhere with bigger screen)------------ START OF SCRIPT -------------
@echo off
ver | find "2003" > nul
if %ERRORLEVEL% == 0 goto ver_2003
ver | find "XP" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "2000" > nul
if %ERRORLEVEL% == 0 goto ver_2000
ver | find "NT" > nul
if %ERRORLEVEL% == 0 goto ver_nt
if not exist %SystemRoot%\system32\systeminfo.exe goto warnthenexit
systeminfo | find "OS Name" > %TEMP%\osname.txt
FOR /F "usebackq delims=: tokens=2" %%i IN (%TEMP%\osname.txt) DO set vers=%%i
echo %vers% | find "Windows 7" > nul
if %ERRORLEVEL% == 0 goto ver_7
echo %vers% | find "Windows Server 2008" > nul
if %ERRORLEVEL% == 0 goto ver_2008
echo %vers% | find "Windows Vista" > nul
if %ERRORLEVEL% == 0 goto ver_vista
goto warnthenexit
:ver_7
:Run Windows 7 specific commands here.
@rem =====================================
@rem check if wallpaper exist on local C:\
@rem if not, copy from network share
@rem =====================================
@if not exist "%systemroot%\System32\oobe\info\backgrounds\backgroundDefault.jpg"
(
copy \\serverName\hiddenShare$\imageFile.jpg %systemroot%\System32\oobe\info\backgrounds\backgroundDefault.jpg
) else (
@rem ====================================
@rem copy file from network if it's newer
@rem ====================================
xcopy \\serverName\hiddenShare$\imageFile.jpg %systemroot%\System32\oobe\info\backgrounds\backgroundDefault.jpg /d /i /y
)
@rem ==========================================
@rem check if regKey for logon wallpaper is set
@rem if not, modify it to point to the new file
@rem ==========================================
reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background" /v OEMBackground | find "1"
if %ERRORLEVEL% == 1
(
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background" /v OEMBackground /t REG_DWORD /d 1 /f
)
reg query "HKLM\SOFTWARE\Policies\Microsoft\Windows\System" /v UseOEMBackground | find "1"
if %ERRORLEVEL% == 1
(
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\System" /v UseOEMBackground /t REG_DWORD /d 1 /f
)
goto exit
:ver_2008
:Run Windows Server 2008 specific commands here.
echo Windows Server 2008
goto exit
:ver_vista
:Run Windows Vista specific commands here.
echo Windows Vista
goto exit
:ver_2003
:Run Windows Server 2003 specific commands here.
echo Windows Server 2003
goto exit
:ver_xp
:Run Windows XP specific commands here.
@rem =====================================
@rem check if wallpaper exist on local C:\
@rem if not, copy from network share
@rem =====================================
@if not exist "%systemroot%\Web\Wallpaper\imageFile.bmp"
(
copy \\serverName\hiddenShare$\imageFile.bmp %systemroot%\Web\Wallpaper\imageFile.bmp
@rem ====================================
@rem copy file from network if it's newer
@rem ====================================
xcopy \\serverName\hiddenShare$\imageFile.bmp %systemroot%\Web\Wallpaper\ /d /i /y
)
@rem ==========================================
@rem check if regKey for logon wallpaper is set
@rem if not, modify it to point to the new file
@rem ==========================================
reg query "HKU\.DEFAULT\Control Panel\Desktop" /v Wallpaper | findstr %systemroot^%\\Web\\Wallpaper\\imageFile.bmp
if %ERRORLEVEL% == 1
(
reg add "HKU\.DEFAULT\Control Panel\Desktop" /v Wallpaper /d %%systemroot%%\Web\Wallpaper\imageFile.bmp /f
)
goto exit
:ver_2000
:Run Windows 2000 specific commands here.
echo Windows 2000
goto exit
:ver_nt
:Run Windows NT specific commands here.
echo Windows NT
goto exit
:warnthenexit
echo Machine undetermined.
:exit------------- END OF SCRIPT -------------
hope that works for you :)
Andrew P.- Marked As Answer by p.andrew Wednesday, September 21, 2011 12:13 AM
-
Monday, November 26, 2012 3:33 AM
Hi,
Where do i put the Image for all users to pick? server share?
AS
-
Monday, November 26, 2012 3:48 AM
It's better to put it on a sever share, make sure to set the permission for everyone to have read access.
Andrew P.
-
Monday, November 26, 2012 4:24 AM
Guys and gals. This topic has been closed for more than two years. Start a new topic with your questions.
¯\_(ツ)_/¯

