创建vbscript来更改win7home机器上的默认墙纸 [英] creating vbscript to change defualt wallpaper on win7home machines

查看:71
本文介绍了创建vbscript来更改win7home机器上的默认墙纸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要帮助使此脚本正确.我相信第一部分已完成文件,但是注册表需要从信息4-8中反映出来,谢谢.

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'此vbscript应命名为DefualtWallpaper.vbs

1 'this vbscript should be named DefualtWallpaper.vbs

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

2 'copy this file to a folder.

3'cat.jpg图片应与vbscript放在同一文件夹中.

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.'将注册表更改为新文件

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. 我在microsft VBScript编译错误中在第18行的错误处出现了char 54错误,预期的结束"代码为800A03f6.在Win 7 Home 64bit上,
  2. 键名:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes
  3. 键类型:REG_EXPAND_SZ
  4. 键:DesktopBackground
  5. 数据:%WINDIR%\WINDOWS\Web\Wallpaper\Windows\cat.bmp
  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

推荐答案

此VBScript用于:

This VBScript for:

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

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

这篇关于创建vbscript来更改win7home机器上的默认墙纸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆