private void button3_Click(object sender, EventArgs e) { string path = textBox1.Text; if (string.IsNullOrEmpty(path)) { return; } if (!Directory.Exists(path)) { MessageBox.Show("No such directory!"); return; } textBox2.Clear(); var files = Directory.GetFiles(path, "*.dll", SearchOption.AllDirectories); var publisher = new Publish(); foreach (var file in files) { try { publisher.GacRemove(file); log("PROCESSED: " + Path.GetFileName(file)); Application.DoEvents(); } catch (Exception ex) { log("ERROR: " + ex.Message); } } }
private static void RemoveAssembly(Kernel kernel) { Publish publish = new Publish(); string file = kernel.CommandLine["remove"]; publish.GacRemove(file); }
public static void GacRemove(string AssemblyPath) { if (!System.IO.File.Exists(AssemblyPath)) { return; } publish.GacRemove(AssemblyPath); }
static void Main(string[] args) { try { if (args.Length == 0) { return; } Publish p = new Publish(); if (args[0] == "/install") { p.GacInstall("EntitySpaces.Common.dll"); p.GacInstall("EntitySpaces.MetadataEngine.dll"); p.GacInstall("EntitySpaces2019.AddIn.dll"); p.GacInstall("EntitySpaces.AddIn.TemplateUI.dll"); p.GacInstall("EntitySpaces.CodeGenerator.dll"); } else if (args[0] == "/remove") { p.GacRemove("EntitySpaces.MetadataEngine.dll"); p.GacRemove("EntitySpaces2019.AddIn.dll"); p.GacRemove("EntitySpaces.AddIn.TemplateUI.dll"); p.GacRemove("EntitySpaces.CodeGenerator.dll"); p.GacRemove("EntitySpaces.TemplateUI.dll"); p.GacRemove("EntitySpaces.MSDASC.dll"); p.GacRemove("EntitySpaces.Common.dll"); } } catch { } }
static void Main(string[] args) { //System.Console.Out.WriteLine("arguments: "+args.Length); try { if (args.Length == 2) { Publish p = new Publish(); if (args[0] == "install") { System.Console.Out.WriteLine("Registering {0} into GAC", args[1]); p.GacInstall(args[1]); } else if (args[0] == "remove") { System.Console.Out.WriteLine("Removing {0} from GAC", args[1]); p.GacRemove(args[1]); } else if (args[0] == "installasm") { System.Console.Out.WriteLine("Registering Assembly {0}", args[1]); RegistrationServices regsrv = new System.Runtime.InteropServices.RegistrationServices(); Assembly ass = Assembly.LoadFrom(args[1]); regsrv.RegisterAssembly(ass, System.Runtime.InteropServices.AssemblyRegistrationFlags.SetCodeBase); //p.RegisterAssembly(args[1]); } else if (args[0] == "removeasm") { System.Console.Out.WriteLine("Removing Assembly {0}", args[1]); RegistrationServices regsrv = new System.Runtime.InteropServices.RegistrationServices(); Assembly ass = Assembly.LoadFrom(args[1]); regsrv.UnregisterAssembly(ass); //p.UnRegisterAssembly(args[1]); } else { displayUsage(); } } else { displayUsage(); } } catch (Exception E) { String s = "Error " + E.Source + " while " + args[0] + " " + args[1] + ": " + E.Message; s = DateTime.Now.ToString() + " " + s; System.Console.Out.WriteLine(s); } }
public static void RemoveAssembly(string assemblyPath) { var publish = new Publish(); try { publish.GacRemove(assemblyPath.Trim()); } catch (FileNotFoundException) { // Do nothing. If the assembly is not there // then we expect this to happen. } }
static int Main(string[] args) { int nRet = 0; if (args.Length == 0) { //show usage string usage = " no parameters defined\n usage: gac-utility <-i><-u> assembly path"; Console.WriteLine(usage); nRet = -1; } else if (args[0] == "-i") { if (System.Reflection.Assembly.LoadFile(args[1]).GetName().GetPublicKey().Length > 0) { Publish objPublish = new Publish(); Console.WriteLine("Adding {0} to GAC", args[1]); try { objPublish.GacInstall(args[1]); } catch (Exception e) { Console.WriteLine("Error {0} Cannot add assembly to GAC!", e); nRet = -1; } } else { Console.WriteLine("Error {0} not signed cannot add to GAC!", args[1]); nRet = -1; } } else if (args[0] == "-u") { Publish objPublish = new Publish(); Console.WriteLine("Removing {0} from GAC", args[1]); try { objPublish.GacRemove(args[1]); nRet = 0; } catch (Exception e) { Console.WriteLine("Error {0} Cannot remove assembly from GAC?", e); nRet = -1; } } return(nRet); }
internal static void RemoveAssemblyFromGAC(string assemblyToCheck) { try { var assembliesToRemove = new Collection <string>(); var gac35 = "c:\\windows\\assembly\\gac_msil"; var gac40 = "c:\\windows\\microsoft.net\\assembly\\gac_msil"; var gacSubFormat = "{0}\\{1}.dll"; var gacFormat = "{0}\\{1}"; var directory35 = string.Format(CultureInfo.InvariantCulture, gacFormat, gac35, assemblyToCheck); var directory40 = string.Format(CultureInfo.InvariantCulture, gacFormat, gac40, assemblyToCheck); foreach (var directory in new Collection <string> { directory35, directory40 }) { if (Directory.Exists(directory)) { foreach (var subdirectory in Directory.GetDirectories(directory)) { var fileToCheck = string.Format(CultureInfo.InvariantCulture, gacSubFormat, subdirectory, assemblyToCheck); if (File.Exists(fileToCheck)) { assembliesToRemove.Add(fileToCheck); } } } } foreach (var assemblyToRemove in assembliesToRemove) { try { var publish = new Publish(); publish.GacRemove(assemblyToRemove); } catch { } } } catch { } }
public override void Uninstall(IDictionary savedState) { try { Publish publish = new Publish(); publish.GacRemove("WhereMyImplant.dll"); ManagementClass managementClass = new ManagementClass(@"root\cimv2:Win32_Implant"); managementClass.Delete(); } catch (Exception ex) { Console.WriteLine(ex.Message); } try { base.Uninstall(savedState); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
static int Main(string[] args) { bool doInstall; string filePath; string finalDirPath; string action; int dirArgIndx; if (args == null || args.Length == 0) { ShowUsage(); return(1); } if (args[0] == "-u" || args[0] == "/u") { doInstall = false; filePath = args[1]; action = "Uninstallation"; dirArgIndx = 2; } else { doInstall = true; filePath = args[0]; action = "Installation"; dirArgIndx = 1; } try { if (args.Length == dirArgIndx) { finalDirPath = Path.GetDirectoryName(filePath); if (finalDirPath == null || finalDirPath.Length == 0) { finalDirPath = "."; } } else if (args.Length == (dirArgIndx + 1)) { finalDirPath = args[dirArgIndx]; } else { ShowUsage(); return(1); } Publish publish = new Publish(); if (!File.Exists(filePath)) { throw new FileNotFoundException("Given file " + filePath + " does not exist."); } if (!Directory.Exists(finalDirPath)) { throw new DirectoryNotFoundException("Given directory " + finalDirPath + " does not exist."); } filePath = Path.GetFullPath(filePath); finalDirPath = Path.GetFullPath(finalDirPath); RegistryKey dotNETAssemblyFoldersKey = Registry.LocalMachine.OpenSubKey(DOTNETAssemblyFoldersKey, true); if (dotNETAssemblyFoldersKey != null) { dotNETAssemblyFoldersKey.DeleteSubKey(GeodeProductKey, false); } if (doInstall) { publish.GacInstall(filePath); if (dotNETAssemblyFoldersKey != null) { RegistryKey productKey = dotNETAssemblyFoldersKey.CreateSubKey(GeodeProductKey); if (productKey != null) { productKey.SetValue(null, finalDirPath, RegistryValueKind.String); } } } else { publish.GacRemove(filePath); } Console.WriteLine("{0} completed successfully.", action); } catch (Exception ex) { Console.WriteLine("Error while performing {0}: {1}{2}\t{3}", action, ex.GetType(), Environment.NewLine, ex.Message); return(1); } return(0); }
private void InstallProc(bool install) { Publish p = new Publish(); string appPath = this.RegistryApplicationDirectory; try { if (install) { System.Environment.SetEnvironmentVariable("GVIEW4_HOME", appPath, EnvironmentVariableTarget.Machine); } else { System.Environment.SetEnvironmentVariable("GVIEW4_HOME", String.Empty, EnvironmentVariableTarget.Machine); } } catch { } DirectoryInfo di = new DirectoryInfo(Path.Combine(appPath, "Framework")); FileInfo[] dlls = di.GetFiles("*.dll"); foreach (FileInfo fi in dlls) { if (install) { p.GacInstall(fi.FullName); } else { p.GacRemove(fi.FullName); } } // Set Envirment Variables string PATH = System.Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine); string PATH2 = String.Empty; bool foundPath = false; foreach (string path in PATH.Split(';')) { if (path.ToLower() != appPath.ToLower()) { if (PATH2 != String.Empty) { PATH2 += ";"; } PATH2 += path; } else { foundPath = true; } } if (install) { if (!foundPath) { if (PATH2 != String.Empty) { PATH2 += ";"; } PATH2 += appPath; System.Environment.SetEnvironmentVariable("PATH", PATH2); } } else { if (foundPath) { System.Environment.SetEnvironmentVariable("PATH", PATH2, EnvironmentVariableTarget.Machine); } } }
private void Form1_Shown(object sender, EventArgs e) { Publish p = new Publish(); string appPath = Form1.RegistryApplicationDirectory; try { if (_install) { System.Environment.SetEnvironmentVariable("GVIEW4_HOME", appPath + @"\", EnvironmentVariableTarget.Machine); } else { System.Environment.SetEnvironmentVariable("GVIEW4_HOME", String.Empty, EnvironmentVariableTarget.Machine); } } catch { } DirectoryInfo di = new DirectoryInfo(Path.Combine(appPath, "Framework")); FileInfo[] dlls = di.GetFiles("*.dll"); progressBar1.Minimum = 0; progressBar1.Maximum = dlls.Length; progressBar1.Value = 0; foreach (FileInfo fi in dlls) { lblAssembly.Text = fi.FullName; this.Refresh(); if (_install) { p.GacInstall(fi.FullName); } else { p.GacRemove(fi.FullName); } progressBar1.Value++; this.Refresh(); System.Threading.Thread.Sleep(50); } // Set Envirment Variables string PATH = System.Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine); string PATH2 = String.Empty; bool foundPath = false; foreach (string path in PATH.Split(';')) { if (path.ToLower() != appPath.ToLower()) { if (PATH2 != String.Empty) { PATH2 += ";"; } PATH2 += path; } else { foundPath = true; } } if (_install) { if (!foundPath) { if (PATH2 != String.Empty) { PATH2 += ";"; } PATH2 += appPath; System.Environment.SetEnvironmentVariable("PATH", PATH2); } } else { if (foundPath) { System.Environment.SetEnvironmentVariable("PATH", PATH2, EnvironmentVariableTarget.Machine); } } // MapServer.Monitor Service installieren //try //{ // string filename = RegistryApplicationDirectory + @"\gView.MapServer.Monitor.exe"; // FileInfo fi = new FileInfo(filename); // if (fi.Exists) // { // if (_install) // { // UInt32 result = (UInt32)mc.InvokeMethod("Install", new object[] { filename }); // } // else // { // UInt32 result = (UInt32)mc.InvokeMethod("Uninstall", new object[] { filename }); // } // } //} //catch (Exception ex) //{ // MessageBox.Show("Can't " + (_install ? "install" : "uninstall") + " gView.MapServer.Monitor Service...\n" + ex.Message, "Warning"); //} this.Close(); }