2

In SCCM 2007, there were several "Right Click Tools", and with their help it was possible to "reinstall" a package. In SCCM 2012 I still couldn't find a way, how could I reinstall an application?

Let me explain:
I created an installation package from a software, then distributed it as an "Application". Installation finished successfully. One week later a user calls, he is having trouble with this application. The package I created supports the reinstallation(either by removing the software and installing it again, or with a repair functionality). But, in SCCM I have no option(neither found a right click tool which could do that), to reinstall the package. I have to remove it, and then install it again.

I thought I could write a program to that, and create my own "Right Click Tool", but I can't find any information what exactly should I do?

So my questions are:
- Is there a Right Click Tool which can reinstall an application somehow?
- Is there some documentation, where I could get some information about this issue?

I am sure, many others have the same problem. Or I didn't find a way, because there is none? :(

Thanks in advance!

Xm7X
  • 861
  • 1
  • 11
  • 23
kampi
  • 2,362
  • 12
  • 52
  • 91

1 Answers1

3

In our company we would also have to liked this and did some basic research but as it seems no one has done it so far (doesn't mean it's impossible). We also talked to two Microsoft SCCM consultants about it and both said there is currently no way.

The thing is applications are all about the detection method. It is the only thing that will trigger the setup. So if you have a software, and you don't want to deploy it as package (this is still possible and they can still be rerun with tools like Roger Zanders client center), what you can do is use a detection method that you can influence. Like a file or reg key, which you can remove remotely. The application deployment evaluation cycle can be triggered remotely just like all other client actions so this would not be a problem.

Sadly this is only a workaround and I would very much like if someone proves me wrong but so far this is the best we could come up with.

Edit: So you motivated me to dig a little deeper and I also got some really good slides from Microsoft and I found some possible approach:

As the application is all about detection all the time my idea is to fake it.

As far as I can tell detection methods are saved in some crazy xml format in the WMI in root\ccm\CIModels in the Class Local_Detect_Synclet. So I wrote a script that goes there and replaces the detection method with an empty detection method that checks for a file. It has no properties so it can never work. After that I call the enforce method on my application using the class CCM_AppDeliveryType in the same namespace. It takes an AppdeliveryTypeID and the current revision but both of those can be seen in CCM_AppDeliveryTypeSynclet. After the enforce reinstalled the program I reset the detection method to the old one and trigger a second enforce which will do nothing but tell the system the app is properly detected. The Vbscript that does all this looks like this:

computername = "WS0000xxxx"

Set wmiCIModels = GetObject("winmgmts:\\" & computername & "\root\ccm\CIModels")
Set wmiAppDeliveryType = GetObject("winmgmts:\\" & computername & "\root\ccm\CIModels:CCM_AppDeliveryType")


deploymentTypeID = "ScopeId_79903130-730F-48B7-8165-6088B83359BE/DeploymentType_68a80836-208e-401b-a69f-ae4c184b9f85"

Set installedDelTypes = wmiCIModels.ExecQuery("select * from Local_Detect_Synclet where AppDeliveryTypeId = '" & deploymentTypeID & "'" )

For Each instDelType In installedDelTypes
    strOldDetectionMethod = instDelType.ExpressionXml
    instDelType.ExpressionXml = "<LocalDetectionMethod><Settings><File></File></Settings><Rule xmlns=""http://schemas.microsoft.com/SystemsCenterConfigurationManager/2009/06/14/Rules""><Expression><Operator>Equals</Operator><Operands><SettingReference AuthoringScopeId="""" DataType=""Version"" SettingLogicalName=""X"" Method=""Value""/><ConstantValue DataType=""Version""/></Operands></Expression></Rule></LocalDetectionMethod>"
    instDelType.Put_ 0

    wmiAppDeliveryType.EnforceApp deploymentTypeID, "4", "", "Install", "", "1"

    instDelType.ExpressionXml = strOldDetectionMethod
    instDelType.Put_ 0

    wmiAppDeliveryType.EnforceApp deploymentTypeID, "4", "", "Install", "", "1" 
Next

The ExpressionXML is horribly long but I deleted everything from it by trial and error that seems possible.

For simplicity I hardcoded the AppdeliveryTypeID and revision but you can get a list of those, including nice names, with the following query:

Set wmiCIModels = GetObject("winmgmts:\\" & computername & "\root\ccm\CIModels")

Set delTypes = wmiCIModels.ExecQuery("select * from CCM_AppDeliveryTypeSynclet" )

For Each delType In delTypes
    WScript.Echo "Deployment Name: " & delType.AppDeliveryTypeName & VbCrLf & "AppdeliveryTypeID: " & delType.AppDeliveryTypeId & VbCrLf & "Revision: " & delType.Revision & VbCrLf
Next

This also presents on of the biggest downsides I found so far. It is only possible to easily get the names of the AppDeliveries. These are not the names the application will show in the Software Center for example. I looked into translating this but the only method I found so far is to query the SCCM DB itself and the query is horribly complicated and needs of course some SCCM admin to execute it.

As with all WMI scripts you can execute it remotely by specifying a computer name or locally if you use '.', so you could use the SCCM Console Extension system and build your own right-click tool based on this.

This will work even on Applications that are not installed similar to the rerun of packages. If you do not want this you can check against CCM_AppDeliveryType to only see the installed applications.

Syberdoor
  • 2,521
  • 1
  • 11
  • 14
  • According to Microsoft, a lot of things are not possible. But then comes someone, and proves they are wrong. I thought about this method you described, and i think too, that this is the only solution. Altough this is not exactly what i am looking for. I am 100% sure there is a solution. (It mustn't be easy, but i am sure there is) – kampi Mar 12 '15 at 10:08
  • Yeah I think it will one day be possible. However I am a little worried that not even in the new SCCM2012 Client Center there is an option for it. This tool can do almost everything SCCM related so it might be really tough. If I ever find out something better than what I proposed I will of course update my post here. – Syberdoor Mar 12 '15 at 12:00
  • Thanks, i will update, my post as well, if i figure out something. – kampi Mar 12 '15 at 12:02
  • @Syberdoor's suggestion seems like it's on the right track. I might do it slightly differently: Make the original application's installer create a flag (eg. file `C:\app-ok.flg`). Then create another "application" that is actually a script that uninstalls the app in question and make its detection depend on the presence of `C:\app-ok.flg`). Then you just delete `C:\app-ok.flg` from the afflicted machines and let the AppEnforce cycles apply the uninstall application, then apply the install application. – alx9r Mar 12 '15 at 21:40
  • Ok i found some way to kinda do it. It is not perfect but it looks like a promising approach so I updated my post accordingly – Syberdoor Mar 13 '15 at 10:26
  • @Syberdoor: This looks very very very promising! I will dig into this. I will try it out, with every scenaio I can think of, and then report back. – kampi Mar 16 '15 at 18:43
  • @Syberdoor:Thanks for your effort. It is working fine, however i have a problem. The `wmiAppDeliveryType.EnforceApp` takes as the 3rd argument the working directory. I have to specify it, otherwise my packages won't work. I dig into the WMI to find a way, to query it, but then it occured me. This will only work if the package is already downloaded locally. So how do i get a package to be downloaded? I can't figure it out. If i have this, my right click tool is ready. – kampi Mar 19 '15 at 22:42
  • I noticed that, too. In our environment we mostly run applications directly form a share, it will work fine without parameter then. But with distribution points the ContentPath is the local ccm cache. I am currently trying to figure out if it is possible to get this path or even better trigger the download. The other thing is that it only works for per machine applications. if it is per user you have to give it the sid. This should be a smaller problem though, definitely solvable somehow, so I currently focus on the contentlocation first. – Syberdoor Mar 20 '15 at 08:19
  • In the `Root\CCM\ClientSDK:CCM_Application` there is a Method called `DownloadContents`. I think this should be responsible for the package download. The only problem, i can't get it work :( I get always `Type mismatch error`. Maybe you have more luck – kampi Mar 20 '15 at 10:59
  • So far I haven't had luck either. I found that you can get the cache via the server in sms\site_:SMS_DeploymentType where you can get the ContentID for the ModelName (i.e. AppDeliveryTypeID) and then give the ContentID to CCM\SoftMgmtAgent:CacheInfoEx for the location in the ccm cache. Only works if present of course. For the other if we cannot DownloadContents to work my final straw is to download the files from the distribution point directly. It's easy with bits but only file per file, whole folder would be a lot less tedious – Syberdoor Mar 20 '15 at 12:01
  • Now we just have to get DownloadContents to work :) I found this on MSDN `https://msdn.microsoft.com/en-us/library/jj885529.aspx` but doesn't help much. Did you notice, that there is also an Install, and Uninstall Method too? Downloading directly from the distribution point? I wouldn't do that. That would mean too much work. There must be a way to get DownloadContents to work. – kampi Mar 20 '15 at 12:16
  • DownloadContents would be nice yeah, but the error messages I get are a little puzzling to me. I know of the (Un)Install methods, but install still uses the appdetect so it does not work if it is installed. If you have uninstall and install defined for all your applications you could try to simulate a re-run by calling uninstall and install immediately again. We have lots of mandatory applications in our environment without uninstall so for us it does not work unfortunately. – Syberdoor Mar 20 '15 at 13:08
  • My Packages support, Instll/Uninstall and even ReInstall. To reinstal a package i just have to start the installation again, and the script will recognize, that the application is already installed, and then execute a reinstall. But that's the smaller problem. Yeah, the errormessages.....I tried to call it every possible way i can think of, but still no luck. – kampi Mar 20 '15 at 13:23