Option Explicit

Dim fso, wsh, svc, thexe_location, reg_path, reg_value, reg_key

WScript.Echo("This script modifies the Windows properties of TH.exe, so the colors are showed correctly in Windows 7. This is saved in the registry database, not in TH.exe.")

Set fso = CreateObject("Scripting.FileSystemObject")
Set wsh = CreateObject("WScript.Shell")
set svc = GetObject("winmgmts:root\default:StdRegProv")

thexe_location = wsh.CurrentDirectory & "\TH.exe"
reg_path       = "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
reg_key        = thexe_location
reg_value      = "256COLOR 640X480 DISABLETHEMES DISABLEDWM HIGHDPIAWARE"

If (fso.FileExists(thexe_location)) Then
 Const HKEY_CLASSES_ROOT   = &H80000000
 Const HKEY_CURRENT_USER   = &H80000001
 Const HKEY_LOCAL_MACHINE  = &H80000002
 Const HKEY_USERS          = &H80000003
 Const HKEY_CURRENT_CONFIG = &H80000005

 If svc.SetStringValue(HKEY_CURRENT_USER,reg_path,reg_key,reg_value) Then
  wscript.echo("Error writing to the registry database.")

 Else
  wscript.echo("The properties of TH.exe has been modified in the registry database.")

 End If

Else
 WScript.Echo("TH.exe was not found. This script needs to be in the same dir as TH.exe.")

End If

WScript.Quit()