0
votes

I am trying to silently uninstall ALL previous Microsoft software in order to run a vbscript to install Office 365(which works).

This is what works currently. Using the scripts from here: https://marckean.wordpress.com/2013/06/18/fully-automate-removal-of-any-version-office-in-preparation-for-office-365/ From this link I use OffScrub7.vbs & OffScrub10.vbs which uninstalls ALL Office 2010 products and all Office 2007 products in theory, but it doesn't!

After running uninstall scripts above, they still leave Lync 2010 and MS Access Database 2007 (32-bit).

Whats the best way to make sure all previous office products are uninstalled including the above software that was not uninstalled by OffScrub7.vbs & OffScrub10.vbs ? My guess is to find silent vbscripts to uninstall Lync 2010 and MS Access Database 2007 (32-bit)?

1
I was wrong, using the .bat file from the above link to run BOTH Officesrub10 & 07 works. - Benjamin Jones

1 Answers

1
votes

All Microsoft apps can be uninstall using easy c++ code and msi api.

Req.: win 7 pro Works in 32 and 64 bits os.

One mini tool.exe, that may be wrapped in vb script, PowerShell , etc

UPD:

I have a little free time. I want to supplement my answer.

I talked about a little application, but did not show a single line of code.

Now we will correct the matter.

1) Need Win7 Pro, 64 or 32 bits, it does not matter. The project we are going to compile a 32-bit compiler, because our application needs to run on 32 bit and 64 bit OS.

2) Need any Ide, I advise Code :: Blocks.

3) Need mingv32-w64 compiler - more information here -- mingw-w64.org

3.1) It is necessary to install two versions of the compiler for 64 bit and 32 bit operating system, even if you have 32 operating as a host. We need a static library from 64-bit compiler installation.

4) Create a console application

5) Build options for project - to add the static library project libmsi.a

But! in 32-bit installation of the compiler has only the header file mhi.n, but the library itself is not! But it is in the 64 bit version of the installer. Find this static library in your Lib folder of 64 bit compiler installation.

6) Code - Enum applications (source: http://mariusbancila.ro/blog/2011/05/01/finding-installed-applications-with-vc/)

The utility must be run with administrator privileges.

That is, if we run the utility from powershell script, then powershell should be run with administrator rights.

#include <iostream>
#include <windows.h>
#include <tchar.h>
#include <msi.h>
#include <string>

using namespace std;

string MsiQueryProperty(LPCTSTR szProductCode,
                     LPCTSTR szUserSid,
                     MSIINSTALLCONTEXT dwContext,
                     LPCTSTR szProperty)
{
    string value;
    DWORD cchValue = 0;
    UINT ret2 = ::MsiGetProductInfoEx(
        szProductCode,
        szUserSid,
        dwContext,
        szProperty,
        NULL,
        &cchValue);
    if(ret2 == ERROR_SUCCESS)
    {
        cchValue++;
        value.resize(cchValue);
        ret2 = ::MsiGetProductInfoEx(
            szProductCode,
            szUserSid,
            dwContext,
            szProperty,
            (LPTSTR)&value[0],
            &cchValue);
    }
    return value;
}

void MsiEnum()
{
    UINT ret = 0;
    DWORD dwIndex = 0;
    TCHAR szInstalledProductCode[39] = {0};
    TCHAR szSid[128] = {0};
    DWORD cchSid;
    MSIINSTALLCONTEXT dwInstalledContext;
    do
    {
        memset(szInstalledProductCode, 0, sizeof(szInstalledProductCode));
        cchSid = sizeof(szSid)/sizeof(szSid[0]);
        ret = ::MsiEnumProductsEx(
            NULL,           // all the products in the context
            _T("s-1-1-0"),  // i.e.Everyone, all users in the system
            MSIINSTALLCONTEXT_USERMANAGED | MSIINSTALLCONTEXT_USERUNMANAGED | MSIINSTALLCONTEXT_MACHINE,
            dwIndex,
            szInstalledProductCode,
            &dwInstalledContext,
            szSid,
            &cchSid);
        if(ret == ERROR_SUCCESS)
        {
            string name = MsiQueryProperty(
                szInstalledProductCode,
                cchSid == 0 ? NULL : szSid,
                dwInstalledContext,
                INSTALLPROPERTY_INSTALLEDPRODUCTNAME);
            string publisher = MsiQueryProperty(
                szInstalledProductCode,
                cchSid == 0 ? NULL : szSid,
                dwInstalledContext,
                INSTALLPROPERTY_PUBLISHER);
            string version = MsiQueryProperty(
                szInstalledProductCode,
                cchSid == 0 ? NULL : szSid,
                dwInstalledContext,
                INSTALLPROPERTY_VERSIONSTRING);
            string location = MsiQueryProperty(
                szInstalledProductCode,
                cchSid == 0 ? NULL : szSid,
                dwInstalledContext,
                INSTALLPROPERTY_INSTALLLOCATION);

            cout << name << endl;
            cout << "  - " << publisher << endl;
            cout << "  - " << version << endl;
            cout << "  - " << location << endl;
            cout << endl;
            dwIndex++;
        }
    }
    while(ret == ERROR_SUCCESS);
}

int main()
{
    MsiEnum();
    return 0;
}

After a time will add the code, remove the application on his behalf, which is displayed in the list of installed programs in the Control Panel.

Just not enough time, sad = (

But you can try is to write an application (if you're interested, nothing fancy really, but still very interesting)