There's a lot of different ways to do this check:
- rewrite your check in nsh (do you need to use vbs? what are you looking for) or some other native form (like something that can be used in a compliance rule) and then use that to drive installation of your package
- use an extended object wrapper to copy and nexec the vbs script and use this in a compliance rule + remediation
- put it in the blpackage directly and execute it and if it doesn't return what you want fail so the actual install doesn't run
- use a batch job that includes a nsh or other job type that does the vbs script and if that fails don't execute the next job in the batch which i'm assuming would be the payload install.
Do not want to create an extended object also do not use compliance. Want to be simplest way. Maybe creating blpackage adding both the application to be installed then importing the vbs as an object and adding that to the blpackage with a command to run the vbs will be the simplest way.
But you are doing compliance here – you are seeing if some condition is met or not and then based on that you are taking an action. Just because you are “deploying” something doesn’t mean you can’t use compliance to drive it.
This VB script actually uses powershell to set compatibility mode on the application in am installing on the targets. Not sure If i can embed this code into NSH script
On Error Resume Next
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
'Define a key registry path
strKeyPath = "\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
objRegistry.CreateKey HKEY_LOCAL_MACHINE, strKeyPath
strValueName = "F:\Application.exe"
strValue = "RUNASADMIN"
objRegistry.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
WScript.Echo "Set the compatibility modes of application successfully."
so what is doing the 'check' ? this looks like it does the set.
This is strictly for testing. No check is needed. Only setting the compatibility mode at this point.
ok so this: "but need to also check windows compatibility after. I have a VBS script that does it for me" isn't really being done here - i mean, there's no vbs script that is doing a 'check of windows compatibility after'?
if you just need to run a vbs script in bsa then you can put it in the blpackage directly and in an external command call it. a type 3 nsh job would expect to be in batch on windows so i don't think that would work.
I just realized I put "Check" and not "set" in the header. My fault. I think BLpackage just running external command would be easiest way. Just wanted confirmation.
Yep – in that case, the vbs script directly in the blpackage and an external command to call it makes the most sense.