Question

Need help making this script true. i beleave the first part is done file, but registry needs to be reflected from information 4-8 thank you.

1 'this vbscript should be named DefualtWallpaper.vbs

2 'copy this file to a folder.

3 'cat.jpg image should be in same folder as vbscript.

dim filesys
set filesys=CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("%cd%\cat.jpg%") Then
filesys.CopyFile "%cd%\cat.jpg%","%windir%\web\wallpaper\windows"

4.'change registry to new file

Set WShellObj=createobject("WScriptShell")
WShellObject.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\DesktopBackground","%WINDIR%\WINDOWS\Web\Wallpaper\Windows\cat.bmp","REG_EXPAND_SZ"
Set WShellObj=nothing
  1. i get a error at line 18 char 54 error expected 'end' code 800A03f6 from microsft VBScript combilation error. on a win 7 home 64bit,
  2. Key name: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes
  3. keytype: REG_EXPAND_SZ
  4. key: DesktopBackground
  5. Data: %WINDIR%\WINDOWS\Web\Wallpaper\Windows\cat.bmp

No correct solution

OTHER TIPS

Try this one from spicework forum:

reg.exe load HKU\DefUser "C:\Documents and Settings\Default User\ntuser.dat"
reg.exe add "HKU\DefUser\Control Panel\Desktop" /v Wallpaper /d "c:\windows\wallpaper\desktop.bmp" /f
reg.exe unload HKU\DefUser

The link is here: http://community.spiceworks.com/scripts/show/327-batch-file-to-set-the-default-wallpaper

This VBScript for:

1-Run script as administrator
2-Copy my image to the directory where the background image saved
3-Change the current desk background image to my image From registry
4-Force Log off the current user to apply the change

'run the script as Administrator
If WScript.Arguments.Length=0 Then
CreateObject("Shell.Application").ShellExecute "wscript.exe",Chr(34)&WScript.ScriptFullName&Chr(34)&" Admin",Null,"runas",1
WScript.Quit 
End If 
'copy the image from to
Dim WShellObj : Set WShellObj=createobject("WScript.Shell")
Dim filesys   : set filesys=CreateObject("Scripting.FileSystemObject")
If filesys.FileExists(WShellObj.ExpandEnvironmentStrings("%cd%")&"\cat.jpg") Then
WShellObj.Run "cmd.exe /c copy ""%cd%\cat.jpg""  %windir%\web\wallpaper\windows",0,False
End If 
'change desktop wallpaper through registry
WShellObj.RegWrite  "HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper","%WINDIR%\Web\Wallpaper\Windows\cat.jpg","REG_SZ"

'force log off to apply the change of wallpaper
Dim oSystem
For Each oSystem In  GetObject ("winmgmts:{(Shutdown)}//./root/cimv2").ExecQuery("select * from Win32_OperatingSystem")
  oSystem.Win32Shutdown 4
Next
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top