如何以编程方式卸载当前用户安装的软件 [英] How to uninstall software installed on current user programmatically
本文介绍了如何以编程方式卸载当前用户安装的软件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试了各种代码,通过编程方式卸载当前用户安装的软件,但每次都失败了。请尽快帮助解决这个问题...
I tried various codes for uninstalling software installed on current user by programmatically but failed each time. Please help to solve this ASAP...
推荐答案
HI,请看下面这些链接以获得帮助,希望能有所帮助
< br $> b $ b
如何列出计算机上安装的所有程序并卸载它们[ ^ ]
以编程方式(使用WMI)卸载应用程序 [ ^ ]
please see these links below for your help, hope it will help
How to list all Programs installed on Computer and Uninstall Them [^]
Uninstalling applications programmatically (with WMI)[^]
您是否尝试在Google上搜索:
使用c#以编程方式卸载软件 - Stack Overflow [ ^ ]
.net - 如何通过调用注册表中列出的软件UninstallString使用c#卸载软件该软件的文件但过程不起作用 - 堆栈溢出 [ ^ ]
通过c#程序卸载软件 [ ^ ]
C# - 安装和卸载软件 [ ^ ]
Did you try searching on google :
Programatically Uninstall a Software using c# - Stack Overflow[^]
.net - How to uninstall Software using c# by calling Software UninstallString Listed in Registry file of that Software But the Process Is Not Working - Stack Overflow[^]
Uninstall a software through c# program[^]
C# - Installing and uninstalling software[^]
首先感谢Rajesh& Deepankar提供了很多帮助我的信息链接。
我通过Registry.CurrentUser获取当前用户的已安装软件的注册表值来完成我的代码,因为我没有通过Registry.LocalMachine得到它。
Hi,
First of all THANKS to Rajesh & Deepankar for the great information links which helped me a lot.
I done my code by getting registry value of installed software on current user by "Registry.CurrentUser" because i didn't get it by "Registry.LocalMachine".
private void Form1_Load(object sender, EventArgs e)
{
this.Visible=false;
this.Refresh();
string AppName = "Acts Analysis";
RegistryKey myRegKey = Registry.CurrentUser;
myRegKey = myRegKey.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall");
String[] subkeyNames = myRegKey.GetSubKeyNames();
if (subkeyNames.Length > 0)
{
foreach (String s in subkeyNames)
{
RegistryKey UninstallKey = Registry.CurrentUser;
UninstallKey = UninstallKey.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + s);
Object oValue = UninstallKey.GetValue("DisplayName");
if (oValue != null)
{
if (oValue.ToString() == AppName)
{
Process[] rundll32Processes = Process.GetProcessesByName("rundll32");
rundll32ProcessesCount = rundll32Processes.Length;
oValue = UninstallKey.GetValue("UninstallString");
oValue = oValue.ToString().Replace("rundll32.exe ", "").ToString();
Process p = new Process();
p.StartInfo.FileName = "rundll32.exe";
p.StartInfo.Arguments = oValue.ToString();
p.Start();
checkUI = false;
tmrFirstInput.Start();
break;
}
}
}
}
else
{
this.Close();
}
}
这篇关于如何以编程方式卸载当前用户安装的软件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文