【问题标题】:creating vbscript to change defualt wallpaper on win7home machines创建 vbscript 以更改 win 7 家用机器上的默认壁纸
【发布时间】:2014-03-25 03:41:50
【问题描述】:

需要帮助使这个脚本成为现实。我相信第一部分是完成文件,但注册表需要从信息 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
  1. 我在第 18 行收到一个错误 char 54 error expected 'end' code 800A03f6 from microsft VBScript combilation error。在 win 7 主场 64 位,
  2. 键名:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes
  3. 键类型:REG_EXPAND_SZ
  4. 键:DesktopBackground
  5. 数据:%WINDIR%\WINDOWS\Web\Wallpaper\Windows\cat.bmp

【问题讨论】:

  • 由于没有 End If 而出现的错误。如果没有以管理员身份运行,您将无法更改注册表中的大部分键,或者仅复制 Windows 目录中的关键文件。并且在输入正确的名称或代码时还有其他错误。

标签: vbscript windows-7 registry settings desktop


【解决方案1】:

从香料论坛试试这个:

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

【讨论】:

    【解决方案2】:

    此 VBScript 用于:

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

    '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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-04
      • 2016-12-11
      • 2014-05-28
      • 2011-07-10
      • 1970-01-01
      • 1970-01-01
      • 2018-08-28
      • 1970-01-01
      相关资源
      最近更新 更多