在 Windows XP 或 Windows 7 中更改主题(静默)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7114747/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 17:53:52  来源:igfitidea点击:

Change theme in Windows XP or Windows 7 (silently)

windowswinapiuser-interfaceregistrywindows-themes

提问by Phillip

could you please help me?

请你帮助我好吗?

What I need is a method to change the theme on a Windows machine without prompting the user with the display properties (personalization) window. The themechange should apply a .theme file from the c:\windows\resources\themes\ directory and NOT apply a new .msstyles. Method should only apply a .theme file. I have just been unable to find a way to apply the theme without causing the personalization window to appear. To emphasize, I dont want to solve this via scripts or macros. And also, closing the window via "sendkeys" is not an option, because it will still be seen momentarily.

我需要的是一种在 Windows 机器上更改主题而不用显示属性(个性化)窗口提示用户的方法。主题更改应应用 c:\windows\resources\themes\ 目录中的 .theme 文件,而不应用新的 .msstyles。方法应该只应用一个 .theme 文件。我一直无法找到一种方法来应用主题而不导致个性化窗口出现。强调一下,我不想通过脚本或宏来解决这个问题。而且,通过“sendkeys”关闭窗口也不是一种选择,因为它仍然会被暂时看到。

Maybe there is a way out through WINAPI function or simple registry hack? Please, give me advice. Thank you.

也许有办法通过 WINAPI 函数或简单的注册表破解?请给我建议。谢谢你。

Best regards

此致

回答by stevenforwords

'Script name: yourtheme.vbs
'Object: Automate without command prompt the application of a Windows Theme by a VB script
'
'SCRIPT CONTENTS:
'Define Variables : 

    Set ShellApp = CreateObject("Shell.Application")
    Set WsShell = CreateObject("Wscript.Shell")


'
'Define path for your file theme (put it on a network share and don't forget to apply "read and execute" ACL for your Users)

    Theme = "typeyoursharepath\typeyourtheme.theme"
    Theme = """" + Theme + """"


'Open Display Properties Windows, Select your theme and apply with keep focus on Windows

    ShellApp.ControlPanelItem cstr("desk.cpl desk,@Themes /Action:OpenTheme /file:" & Theme)
    Wscript.Sleep 100
    WsShell.SendKeys "{ENTER}"
    While WsShell.AppActivate ("Display Properties") = TRUE
        WsShell.AppActivate "Display Properties"
    Wend

'In case of problem try to use a timeout value more important like "Wscript.Sleep 2000"
'END OF SCRIPT 

'NOTES:
'APPLIED SUCCESSFULLY ON WINDOWS XP AND WINDOWS SERVER 2003R2 X86   AND UNDER CITRIX XENAPP 4.6FP7 (OS: W2003R2X86 SP2) TO APPLY WINDOWS EMBEDDED THEME WITH BLUE BACKGROUND COLOR MORE LIGHT. 
'LOOKS GREAT ON CITRIX SESSION USER!
'INTEGRATED IN USER CONFIG GPO AT USER LOGON UNDER CITRIX XENAPP.

回答by Robith Nuriel Haq

I don't think there is a native way to change Windows 7's (and windows 8's) theme silently, but you can try to use winaero theme switcher. you can read about and download it here.

我认为没有一种本地方式可以静默更改 Windows 7(和 Windows 8)的主题,但您可以尝试使用 winaero 主题切换器。您可以在此处阅读并下载它。