我正在尝试静默卸载所有以前的Microsoft软件,以便运行vbscript来安装Office 365(可以正常工作)。
这就是目前有效的方法。使用脚本从这里:https://marckean.wordpress.com/2013/06/18/fully-automate-removal-of-any-version-office-in-preparation-for-office-365/从这个链接我使用OffScrub7.vbs & OffScrub10.vbs,它卸载所有Office2010产品和所有Office2007产品理论上,但它没有!
运行上述卸载脚本后,它们仍保留Lync 2010和MS Access Database 2007 (32位)。
确保卸载所有以前的office产品的最好方法是什么,包括上面提到的未被OffScrub7.vbs & OffScrub10.vbs卸载的软件?我的猜测是找到静默的vbscript来卸载Lync 2010和MS Access数据库2007 (32位)?
发布于 2015-09-23 21:29:38
所有微软应用程序都可以使用easy c++代码和msi api卸载。
请求: win 7 pro可在32位和64位操作系统下运行。
一个迷你脚本,可以封装在vb tool.exe、PowerShell等中
更新:
我有一点空闲时间。我想补充一下我的答案。
我谈到了一个小应用程序,但没有显示一行代码。
现在我们将纠正这个问题。
1)需要Win7专业版,64位或32位,无关紧要。该项目我们将编译一个32位编译器,因为我们的应用程序需要在32位和64位操作系统上运行。
2)需要任何Ide,我建议Code ::Blocks。
3)需要mingv32-w64编译器--更多信息在这里-- mingw-w64.org
3.1)即使您有32位操作系统作为主机,也需要安装64位和32位操作系统的两个版本的编译器。我们需要来自64位编译器安装的静态库。
4)创建控制台应用程序
5)项目的构建选项-添加静态库项目libmsi.a
但!在32位安装的编译器中只有mhi.n头文件,而库本身却没有!但它是在安装程序的64位版本中。在64位编译器安装的Lib文件夹中找到这个静态库。
6)代码-枚举应用程序(来源:http://mariusbancila.ro/blog/2011/05/01/finding-installed-applications-with-vc/)
该实用程序必须以管理员权限运行。
也就是说,如果我们从powershell脚本运行该实用程序,则powershell应该以管理员权限运行。
#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;
}
过一段时间会添加代码,代为删除应用程序,它会显示在控制面板中的已安装程序列表中。
只是没有足够的时间,悲伤=(
但是你可以试着写一个应用程序(如果你感兴趣,没什么特别的,但仍然很有趣)
https://stackoverflow.com/questions/32740675
复制相似问题