I have a peice of software that I am trying to automate the install with SCCM 2012 R2. Everything install correctly with the MSI + MST, however in order for the program to work correctly, the program needs to be ran in Windows XP SP3 Compatiblity Mode.  To fix this I created a VB script to write to correct location in the registry, that will set the correct setting, however the app does not recognize the key.  It will recognize the key but only after I reboot the PC, and then go into the Compatiblity tab of the EXE in question.  I don't need to modify or add any thing, just go into the tab(when I do, it does show that the compatibily mode is set to WINXPSP3), after that the program opens in the correct mode.  I have attached the function that is creating the regkey.


Set objRegistry=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"& strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\"
strKey = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
strValue = "WINXPSP3"

If bl64bit = True Then
strValueName = "C:\Program Files (x86)\program.exe"
strValueName = "C:\Program Files\Program.exe"
End If

intkeyReturn = objRegistry.CreateKey(HKLM, strKey)
If intkeyReturn = 0 Then
intkeyReturn = objRegistry.SetStringValue(HKLM,strKeyPath,strValueName,strValue)
End If
0 Comments   [ + ] Show Comments


Please log in to comment



I had similar issues at one point. Especially when running on a 64-bit machine. What I found was that the VBScript was writing to the Wow6432Node instead of in the base HKLM\SOFTWARE. I had to use the code below to force writing to the correct registry location:

Set objCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
objCtx.Add "__ProviderArchitecture", nbits
objCtx.Add "__RequiredArchitecture", True
Set objLocator = CreateObject("Wbemscripting.SWbemLocator")
Set objServices = objLocator.ConnectServer("","root\default","","",,,,objCtx)
Set objStdRegProv = objServices.Get("StdRegProv")rpath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
if nbits = 64 Then
 exepath = "C:\Program Files (x86)\Program.exe"
 exepath = "C:\Program Files\Program.exe"
end if
' Use ExecMethod to call the SetStringValue method
Set Inparams = objStdRegProv.Methods_("SetStringValue").Inparameters
Inparams.Hdefkey = HKEY_LOCAL_MACHINE
Inparams.Ssubkeyname = rpath
Inparams.Svaluename = exepath
Inparams.Svalue = "RUNASADMIN"
Set Outparams = objStdRegProv.ExecMethod_("SetStringValue", Inparams,,objCtx)
Essentially, still using the SetStringValue, but inserting addtional params that tell it to write to either the 64-bit or 32-bit registryl
Answered 03/31/2014 by: BHC-Austin
Fourth Degree Black Belt

Please log in to comment

Try HKCU registry to set the compatibility. It may work without reboot.

Answered 04/01/2014 by: Visalakshi
Orange Senior Belt

Please log in to comment

Have you tried using the Application Compatibilty Tool and shim the app making it run as admin?

Answered 04/02/2014 by: mattski
Second Degree Green Belt

Please log in to comment
Answer this question or Comment on this question for clarity