' StarCraft Windows 7 Color Fix Version 1.0 by ABEgorov
' Version: 1.0.0 original
' Copyright (C) Egorov Andrew Borisovich (abegorov@gmail.com)
' Russia, Moscow, 2010
' Tested on Windows 7 64-bit
'THIS SCRIPT IS DISTRIBUTED WITHOUT ANY WARRANTY.
'Anyone can modify it and do with it whatever he wants (if he delete first five line of this file or write in start of script that it was modified).
'Installation:
'1. Open Folder Options by clicking the Start button , clicking Control Panel, clicking Appearance and Personalization, and then clicking Folder Options.
'2. Change advanced file and folder settings.
'3. Select the Launch folder windows in a separate process check box, and then click OK. (This option is absolutely safe and even increase the stability of Windows - see
http://windows.microsoft.com/en-us/w...folder-options for detail.
'4. Reboot computer.
'5. Copy this (StarCraft.vbs) file into StarCraft folder with StarCraft.exe.
'6. Start StarCraft by clicking on StarCraft.vbs instead of StarCraft.exe.
'7. You can change shortcut to starcraft to use this fix by editing it's properties. On shortcut tab simply click "Change Icon", then OK. Change object extension from .exe to .vbs and click Apply.
'Uninstallation:
'1. Delete this (StarCraft.vbs) file.
'2. Restore object extension in starcraft shortcut from .vbs to .exe.
'Known problems:
'* Some hotkey that handled by explorer.exe may not work when you playing StarCraft
'* Start menu and tray will be inaccessable during play StarCraft
'* Some explorer windows (but not all as in other fixes) may be closed when StarCraft start
'* If fix doesn't work - do not use it - it can incorrectly determine explorer process that should be closed (see script code). But it work on my machine.
Option Explicit
'Parameters:
'Name of StarCraft EXE file:
Const strApplicationExe = "StarCraft.exe"
'Should this script kill explorer process if it started from task manager by clicking File->Run and typing explorer.exe? [True/False]
Const bKillExplorerIfItStartedByTaskManager = True
'Should this script kill explorer process if it started by userinit process at logon? [True/False]
Const bKillExplorerIfItStartedByUserInit = True
'Should this script kill explorer process if it restarted after crash by winlogon? [True/False]
Const bKillExplorerIfItStartedByWinlogon = True
'If this script cannot determine application that start explorer.exe process then it kill this explorer.exe process!
'If explorer.exe started by wmiprvse.exe then this script also kill this explorer.exe process.
'This script kill all explorer.exe process that satisfy the above conditions.
Function TerminateShell()
TerminateShell = False
'Intialize WMI
Dim objWMIService
Dim colProcess, objProcess
Dim colExplorer, objExplorer
Dim bExplorerIsShell
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\.\root\cimv2")
If IsNULL(objWMIService) Then
MsgBox "Can not initialize WMI." & vbCrLf _
& "Please ensure that WMI installed on this computer.", vbCritical, _
"WMI Error"
Exit Function
End If
'Get all process collection
Set colProcess = objWMIService.ExecQuery("SELECT * " _
& "FROM Win32_Process")
If IsNULL(colProcess) Then
MsgBox "Can not get list of running processes." & vbCrLf _
& "WMI installed, but cannot be used for getting list of processes. " _
& "May be you security settings doesn't allowed it or " _
& "WMI setup incorrectly. Try reinstall it or repair OS.", vbCritical, _
"WMI Error"
Exit Function
End If
'Get explorer.exe process collection
Set colExplorer = objWMIService.ExecQuery("SELECT * " _
& "FROM Win32_Process WHERE Name LIKE 'explorer.exe'")
If IsNULL(colExplorer) Then
' Nothing to kill, all good, function succeed
TerminateShell = True
Exit Function
End If
'First we need to kill shell. It represented by explorer.exe process.
'Only one explorer.exe process represent a shell
'Shell started by some process that start explorer.exe and finish working.
'So explorer.exe of shell have parent PID of terminated process.
'Searching for explorer.exe process that have PID of not running process.
For Each objExplorer in colExplorer
bExplorerIsShell = True
For Each objProcess in colProcess
If (objExplorer.ParentProcessId = objProcess.ProcessId) Then
bExplorerIsShell = False
If LCase(objProcess.Name) = "wmiprvse.exe" OR _
(bKillExplorerIfItStartedByTaskManager AND _
LCase(objProcess.Name) = "taskmgr.exe") OR _
(bKillExplorerIfItStartedByUserInit AND _
LCase(objProcess.Name) = "userinit.exe") OR _
(bKillExplorerIfItStartedByWinlogon AND _
LCase(objProcess.Name) = "winlogon.exe")Then _
bExplorerIsShell = True
Exit For
End If
Next
'Exit code 1 means that explorer.exe should not be restarted
If bExplorerIsShell Then objExplorer.Terminate(1)
Next
TerminateShell = True
End Function
Function GetScriptDir()
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
GetScriptDir = fso.GetParentFolderName(WScript.ScriptFullName) & "\"
End Function
Function GetWindowsDir()
Dim wshShell, wshSysEnv
Set wshShell = WScript.CreateObject("WScript.Shell")
Set wshSysEnv = wshShell.Environment("Process")
GetWindowsDir = wshSysEnv("WINDIR") + "\"
End Function
Function FileExists(strAppExe)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
FileExists = fso.FileExists(strAppExe)
End Function
Function StartApp(ByVal strAppExe, ByVal bWaitTermination)
Dim wshShell
Set wshShell = WScript.CreateObject("WScript.Shell")
StartApp = WshShell.Run(strAppExe, 10, bWaitTermination)
End Function
Function Main()
Main = 0
If Not FileExists(GetScriptDir() & strApplicationExe) Then
MsgBox "File """ & GetScriptDir() & strApplicationExe _
& """ doesn't exists. Make sure that script located in " _
& "correct directory.", vbCritical, "Cannot find " & strApplicationExe
Exit Function
End If
If TerminateShell() Then
On Error Resume Next
Main = StartApp(GetScriptDir() & strApplicationExe, True)
StartApp GetWindowsDir() & "Explorer.exe", False
End If
End Function
WScript.Quit Main()