Have built what I thought would be a simple application install to install a certificate.
Basically the application runs certmgr.exe with relevant options to install a certificate that is in the same folder as the certmgr.exe. From what I can see, the AppDetection process runs as follows (correct me if i'm wrong)
- Run App Detection script (see below)
- If its not detected, then I can see the certmgr.exe being run and the certificate does get installed and exit code is 0
- The App Detection script is rerun to check it has installed and at this point I get errors in the logfile AppEnforce.log
Script used on Detection Method is:
$store = New-Object System.Security.Cryptography.X509Certificates.X509Store("TrustedPublisher","LocalMachine")
$store.Open("ReadOnly")
$CertFound = ( $store.Certificates | where-object { $_.subject -match "NameOfCertToCheckFor" } )
if ($CertFound -eq $null) { exit $false } else { exit $true }
So, initially cert is not found (correct), certmgr.exe is run (successfully), then cert should be found.
Error showing up in log is as follows:
<![LOG[ Performing detection of app deployment type Certificate Install - NETEHWSUS01 Root CA(ScopeId_59C41283-5F82-44F8-82C6-5A250A061892/DeploymentType_add41049-d008-4584-bf31-680d50b85e40, revision 11) for user.]LOG]!><time="12:35:03.293-60"
date="07-02-2012" component="AppEnforce" context="" type="1" thread="3948" file="appprovider.cpp:2064">
<![LOG[+++ Application not discovered with script detection. [AppDT Id: ScopeId_59C41283-5F82-44F8-82C6-5A250A061892/DeploymentType_add41049-d008-4584-bf31-680d50b85e40, Revision: 11]]LOG]!><time="12:35:04.811-60" date="07-02-2012" component="AppEnforce"
context="" type="1" thread="3948" file="scripthandler.cpp:485">
<![LOG[ App enforcement environment:
Context: Machine
Command line: certmgr.exe /add /c "netehwsus01.cer" /s /r localMachine root
Allow user interaction: No
UI mode: 1
User token: not null
Session Id: 4294967295
Content path: C:\Windows\ccmcache\p
Working directory: ]LOG]!><time="12:35:04.812-60" date="07-02-2012" component="AppEnforce" context="" type="1" thread="3948" file="appcontext.cpp:67">
<![LOG[ Prepared working directory: C:\Windows\ccmcache\p]LOG]!><time="12:35:04.813-60" date="07-02-2012" component="AppEnforce" context="" type="1" thread="3948" file="appcontext.cpp:182">
<![LOG[ Prepared command line: "C:\Windows\ccmcache\p\certmgr.exe" /add /c "netehwsus01.cer" /s /r localMachine root]LOG]!><time="12:35:04.820-60" date="07-02-2012" component="AppEnforce" context="" type="1" thread="3948" file="appcontext.cpp:331">
<![LOG[ Executing Command line: "C:\Windows\ccmcache\p\certmgr.exe" /add /c "netehwsus01.cer" /s /r localMachine root with system context]LOG]!><time="12:35:04.820-60" date="07-02-2012" component="AppEnforce" context="" type="1" thread="3948"
file="appexcnlib.cpp:201">
<![LOG[ Working directory C:\Windows\ccmcache\p]LOG]!><time="12:35:04.821-60" date="07-02-2012" component="AppEnforce" context="" type="1" thread="3948" file="appexcnlib.cpp:215">
<![LOG[ Post install behavior is BasedOnExitCode]LOG]!><time="12:35:04.831-60" date="07-02-2012" component="AppEnforce" context="" type="1" thread="3948" file="appcommon.cpp:1091">
<![LOG[ Waiting for process 1928 to finish. Timeout = 120 minutes.]LOG]!><time="12:35:04.834-60" date="07-02-2012" component="AppEnforce" context="" type="1" thread="3948" file="appexcnlib.cpp:1682">
<![LOG[ Process 1928 terminated with exitcode: 0]LOG]!><time="12:35:05.010-60" date="07-02-2012" component="AppEnforce" context="" type="1" thread="3948" file="appexcnlib.cpp:1691">
<![LOG[ Looking for exit code 0 in exit codes table...]LOG]!><time="12:35:05.011-60" date="07-02-2012" component="AppEnforce" context="" type="1" thread="3948" file="appexcnlib.cpp:315">
<![LOG[ Matched exit code 0 to a Success entry in exit codes table.]LOG]!><time="12:35:05.011-60" date="07-02-2012" component="AppEnforce" context="" type="1" thread="3948" file="appexcnlib.cpp:394">
<![LOG[ Performing detection of app deployment type Certificate Install - NETEHWSUS01 Root CA(ScopeId_59C41283-5F82-44F8-82C6-5A250A061892/DeploymentType_add41049-d008-4584-bf31-680d50b85e40, revision 11) for user.]LOG]!><time="12:35:05.027-60"
date="07-02-2012" component="AppEnforce" context="" type="1" thread="3948" file="appprovider.cpp:2064">
<![LOG[ Script Execution Returned :1, Error Message: (null). [AppDT Id: ScopeId_59C41283-5F82-44F8-82C6-5A250A061892/DeploymentType_add41049-d008-4584-bf31-680d50b85e40, Revision: 11]]LOG]!><time="12:35:06.247-60" date="07-02-2012" component="AppEnforce"
context="" type="3" thread="3948" file="scripthandler.cpp:491">
<![LOG[CScriptHandler::DiscoverApp failed (0x80070001).]LOG]!><time="12:35:06.284-60" date="07-02-2012" component="AppEnforce" context="" type="3" thread="3948" file="scripthandler.cpp:521">
<![LOG[Deployment type detection failed with error 0x80070001.]LOG]!><time="12:35:06.284-60" date="07-02-2012" component="AppEnforce" context="" type="3" thread="3948" file="appprovider.cpp:2119">
<![LOG[++++++ Failed to enforce app. Error 0x80070001. ++++++]LOG]!><time="12:35:06.286-60" date="07-02-2012" component="AppEnforce" context="" type="3" thread="3948" file="appprovider.cpp:2365">
I can't work out what the issue is, and I'm struggling to find any kind of documentation/help regarding Custom Script Detection Methods and what the return codes should be for these detections. Have tried -1,0,1, true and false.
Can anyone help?