private void btnSupersedeApplication_Click(object sender, EventArgs e) { ////retrieve app that was created sccm.Application application = GetApplicationFromName(txtSCCMApplicationName.Text); ////retrieve application that will be superseded sccm.Application appToSupersede = GetApplicationFromName(cmbSuperseded.Items[cmbSuperseded.SelectedIndex] as string); sccm.DeploymentType dt = application.DeploymentTypes[0]; sccm.DeploymentType ssdt = appToSupersede.DeploymentTypes[0]; //// Define an intent expression to describe the realtionship between the applications DeploymentTypeIntentExpression intentExpression = new DeploymentTypeIntentExpression(appToSupersede.Scope, appToSupersede.Name, (int)appToSupersede.Version, ssdt.Scope, ssdt.Name, (int)ssdt.Version, DeploymentTypeDesiredState.Prohibited, true); //// Define a deployment type rule to contain the expression DeploymentTypeRule deploymentRule = new DeploymentTypeRule(NoncomplianceSeverity.None, null, intentExpression); //// Add to Supersedes collection. dt.Supersedes.Add(deploymentRule); SaveApplication(application); }
private void btnAddDependency_Click(object sender, EventArgs e) { ////retrieve the application that requires a dependency sccm.Application application = GetApplicationFromName(txtSCCMApplicationName.Text); ////retrieve the application that will form a dependency sccm.Application dependencyApplication = GetApplicationFromName(cmbDependency.Items[cmbDependency.SelectedIndex] as string); sccm.DeploymentType dependencydeploymentType = dependencyApplication.DeploymentTypes[0]; // define operands in an intent expression and add the information to the dependency CustomCollection <DeploymentTypeIntentExpression> operand = new CustomCollection <DeploymentTypeIntentExpression>(); operand.Add(new DeploymentTypeIntentExpression(dependencyApplication.Scope, dependencyApplication.Name, dependencyApplication.Version.Value, dependencydeploymentType.Scope, dependencydeploymentType.Name, dependencydeploymentType.Version.Value, DeploymentTypeDesiredState.Required, true)); ////create an expression (and/or) for multiple dependencies and then use in a rule which is added to the dependencies collection of the application's deployment type DeploymentTypeExpression expression = new DeploymentTypeExpression(ExpressionOperator.And, operand); DeploymentTypeRule dependencyRule = new DeploymentTypeRule("Dependency_" + Guid.NewGuid().ToString("B"), NoncomplianceSeverity.Critical, null, expression); application.DeploymentTypes[0].Dependencies.Add(dependencyRule); SaveApplication(application); }
private void btnCreateInstallerandDt_Click(object sender, EventArgs e) { ////Setup the installer and it's contents Content content = new Content(); MsiInstaller msiInstaller = new MsiInstaller(); FileInfo file = new FileInfo(txtMSILocation.Text); content.Location = file.Directory.FullName; ////use the msi folders location as the content source for the application package content = ContentImporter.CreateContentFromFolder(file.Directory.FullName); ////set the command that will run to install on a clients desktop msiInstaller.InstallCommandLine = txtInstallCommandLine.Text; msiInstaller.UninstallCommandLine = txtUninstallCommandLine.Text; ContentRef contentReferenece = new ContentRef(content); content.OnFastNetwork = ContentHandlingMode.Download; content.OnSlowNetwork = ContentHandlingMode.DoNothing; content.FallbackToUnprotectedDP = false; ////configure other properties - for instance the produce code which by default is used to detect whether the application is already installed msiInstaller.Contents.Add(content); msiInstaller.InstallContent = contentReferenece; msiInstaller.DetectionMethod = DetectionMethod.ProductCode; msiInstaller.ProductCode = txtProductCode.Text; msiInstaller.SourceUpdateProductCode = txtProductCode.Text; msiInstaller.ExecutionContext = sccm.ExecutionContext.System; msiInstaller.Contents[0].PinOnClient = false; msiInstaller.Contents[0].PeerCache = false; msiInstaller.UserInteractionMode = UserInteractionMode.Normal; msiInstaller.MaxExecuteTime = 120; msiInstaller.ExecuteTime = 0; ////Add a deployment type to the application using the installer details created above sccm.DeploymentType dt = new sccm.DeploymentType(msiInstaller, "MSI", NativeHostingTechnology.TechnologyId); dt.Title = txtSCCMApplicationName.Text; dt.Version = 1; ////retrieve tha application here to then add the deployment type to ot sccm.Application application = GetApplicationFromName(txtSCCMApplicationName.Text); application.DeploymentTypes.Add(dt); ////resave the application SaveApplication(application); }