如果未应用,如何在 Windows 7 上应用某个主题?

How to apply a certain theme on Windows 7 IF it's not applyed?

这里有一些修改后的代码:VB Script to apply certain Windows Theme

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "rundll32.exe %SystemRoot%\system32\shell32.dll,Control_RunDLL %SystemRoot%\system32\desk.cpl desk,@Themes /Action:OpenTheme /file:""%windir%\Resources\Ease of Access Themes\basic.theme"""
Do Until GetWnd(oWnd) 
    WScript.Sleep 10
Loop
'sLocationName = oWnd.LocationName ' debug
oWnd.Quit 
'WScript.Echo sLocationName & " Closed" ' debug


Function GetWnd(oShellWnd)
    On Error Resume Next
    GetWnd = False
    For Each oShellWnd In CreateObject("Shell.Application").Windows
        With oShellWnd
            If InStr(LCase(TypeName(.Document)), "ishell") = 0 Then 
            Else
                If InStr(.Document.Folder.Self.Path, "::{26EE0668-A00A-44D7-9371-BEB064C98683}") = 0 Then
                Else
                    GetWnd = True
                    Exit For
                End If
            End If
        End With
    Next
End Function

我需要添加一个条件来检查活动主题,如果它不是 Access Themes\basic.theme 的 %windir%\Resources\Ease,那么上面的所有代码都会执行。 它应该适用于 Windows 7。 有什么建议吗?

好吧,我已经根据需要对其进行了编码。请放心使用。调试消息未被注释。 脚本适用于 Windows 7,检查注册表中的当前主题,如果不是 basic.theme,则应用它并关闭个性化 window。欢迎使用。

On Error Resume Next
Dim currentTheme,ReadTheme
Set WshShell = WScript.CreateObject("WScript.Shell") 
currentTheme = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\CurrentTheme"
ReadTheme = WSHShell.RegRead(currentTheme)
'---Reading Reg Values
WSHShell.RegRead(currentTheme)
'---Echo Values for debug
'WScript.Echo WshShell.RegRead(currentTheme)

If Err Then
'---Applying theme if error occured
ApplyBasicTheme()   
Else
    If ReadTheme = "C:\Windows\resources\Ease of Access Themes\basic.theme" Then
    WScript.Echo "It's basic" & WshShell.RegRead(currentTheme) & ", nothing to do" ' debug
    Else
    ApplyBasicTheme()       
    End If
End If

Function ApplyBasicTheme()
    Msgbox "Not basic" & WshShell.RegRead(currentTheme) & ", changing", vbExclamation ' debug
    WshShell.Run "rundll32.exe %SystemRoot%\system32\shell32.dll,Control_RunDLL %SystemRoot%\system32\desk.cpl desk,@Themes /Action:OpenTheme /file:""%windir%\Resources\Ease of Access Themes\basic.theme"""
    Do Until GetWnd(oWnd) ' Wait until Personalisation Window appears
        WScript.Sleep 10
    Loop
    'sLocationName = oWnd.LocationName ' debug
    oWnd.Quit ' Close Personalisation Window
    'WScript.Echo sLocationName & " Closed" ' debug
End function

Function GetWnd(oShellWnd)
    On Error Resume Next
    GetWnd = False
        For Each oShellWnd In CreateObject("Shell.Application").Windows
            With oShellWnd
            If InStr(LCase(TypeName(.Document)), "ishell") = 0 Then ' is explorer window, but not internet explorer
            Else
                If InStr(.Document.Folder.Self.Path, "::{26EE0668-A00A-44D7-9371-BEB064C98683}") = 0 Then ' any control panel window
            Else
            GetWnd = True
        Exit For
                End If
            End If
            End With
    Next
End Function
WScript.Quit