首页 文章

创建vbscript来改变win7home机器上的defualt壁纸

提问于
浏览
1

需要帮助使这个脚本成为现实 . 我beleave第一部分是完成文件,但注册表需要反映信息4-8谢谢 .

1'这个vbscript应该命名为DefualtWallpaper.vbs

2'将此文件复制到文件夹 .

3'cat.jpg图像应与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.'将注册表更改为新文件

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
  • 我在第18行出现错误54错误预期'end'代码800A03f6来自microsft VBScript组合错误 . 在赢得7家64位,

  • 键名: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes

  • keytype: REG_EXPAND_SZ

  • 键: DesktopBackground

  • 数据: %WINDIR%\WINDOWS\Web\Wallpaper\Windows\cat.bmp

2 回答

  • 0

    这个VBScript:

    以管理员身份运行1脚本
    2 - 将我的图像复制到保存背景图像的目录
    3 - 将当前桌面背景图像更改为我的图像从注册表
    4-Force注销当前用户以应用更改

    '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
    
  • 2

    从spicework论坛试试这个:

    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
    

    链接在这里:http://community.spiceworks.com/scripts/show/327-batch-file-to-set-the-default-wallpaper

相关问题