对于.NET应用程序,有没有办法运行在卸载过程中自定义操作。上卸载自定义操作(的ClickOnce) - 使用ClickOnce安装.NET
具体来说,我需要删除一些应用程序相关的文件(这是我第一次运行创建),并在卸载过程中调用Web服务。
任何想法?
对于.NET应用程序,有没有办法运行在卸载过程中自定义操作。上卸载自定义操作(的ClickOnce) - 使用ClickOnce安装.NET
具体来说,我需要删除一些应用程序相关的文件(这是我第一次运行创建),并在卸载过程中调用Web服务。
任何想法?
有没有办法做到这一点使用ClickOnce本身,但您可以创建一个标准的Setup.exe引导程序是安装ClickOnce应用程序,并且有一个自定义卸载动作。
注意这个但是这会在添加两个条目/删除程序,所以你需要隐藏的条目之一(的ClickOnce应用程序)。然后
你的最后一个问题将是有上的ClickOnce没有“静默卸载”选项,所以你可以做这样的事情:
On Error Resume Next
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run "taskkill /f /im [your app process name]*"
objShell.Run "[your app uninstall key]"
Do Until Success = True
Success = objShell.AppActivate("[your window title]")
Wscript.Sleep 200
Loop
objShell.SendKeys "OK"
(找到here)
的ClickOnce安装一个卸载注册表键入您的ClickOnce应用程序可访问的HKEY_CURRENT_USER。
的具体位置是“HKEY_CURRENT_USER \ SOFTWARE \微软\的Windows \ CurrentVersion \卸载”
你将不得不寻找与你的应用程序的显示名称的关键。
然后你可以用正常的卸载动作,
string registryKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
Microsoft.Win32.RegistryKey uninstallKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(registryKey);
if (uninstallKey != null)
{
foreach (String a in uninstallKey.GetSubKeyNames())
{
Microsoft.Win32.RegistryKey subkey = uninstallKey.OpenSubKey(a, true);
// Found the Uninstall key for this app.
if (subkey.GetValue("DisplayName").Equals("AppDisplayName"))
{
string uninstallString = subkey.GetValue("UninstallString").ToString();
// Wrap uninstall string with my own command
// In this case a reg delete command to remove a reg key.
string newUninstallString = "cmd /c \"" + uninstallString +
" & reg delete HKEY_CURRENT_USER\\SOFTWARE\\CLASSES\\mykeyv" +
MYAPP_VERSION + " /f\"";
subkey.SetValue("UninstallString", newUninstallString);
subkey.Close();
}
}
}