It turns out that the above was a good theory, but Vista UAC rears its ugly head. The create script ran fine on XP but failed with a permission error on Vista.
Consequently, the custom action needs to run "Deferred with no impersonation". However, a custom action run in this mode doesn't have access to session properties so I had to rewrite the script to get the OS version from the WMI service.
The result is below. If there's an easier way to do any of this, please let me know!
Code: Select all
Dim strComputer : strComputer = "."
Dim objWMI : Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Dim colComputers : Set colComputers = objWMI.ExecQuery("Select * from Win32_OperatingSystem")
Dim objComputer, WinVersion
Dim objShell, EnvVar
For Each objComputer In colComputers
' version string includes subversions so extract first part only
WinVersion = Left(objComputer.Version, InStr(objComputer.Version,".")-1)
Next
' Create an instance of the wshShell object
Set objShell = CreateObject("WScript.Shell")
' Use environment variable of type = system
Set EnvVar = objShell.Environment("System")
' Windows 2000 and Windows XP
If WinVersion < "6" Then
EnvVar("LSHOST") = "no-net"
End If
' Windows Vista and Windows 7
If WinVersion >= "6" Then
EnvVar("LSFORCEHOST") = "no-net"
End If
Scott
FOLLOW US
Get the latest news in Application Packaging