static public void UnInstall() { Action <string> deleteFile = (file) => { try { if (File.Exists(file)) { File.Delete(file); } } catch { } }; try { string oldHomeDir = Environment.GetEnvironmentVariable("CSSCRIPT_DIR"); if (CSScriptInstaller.IsComShellExtInstalled() && File.Exists(CSScriptInstaller.comShellEtxDLL32)) { CSScriptInstaller.UninstallComShellExt(); } string path = ""; using (RegistryKey envVars = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment", true)) { path = Win32.RegGetValueExp(Win32.HKEY_LOCAL_MACHINE, @"SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Path"); RemoveFromPath(@"%CSSCRIPT_DIR%", path); envVars.DeleteValue("CSSCRIPT_DIR", false); } path = RemoveFromPath(@"%CSSCRIPT_DIR%", path); path = RemoveFromPath(@"%CSSCRIPT_DIR%\lib", path); Win32.RegSetStrValue(Win32.HKEY_LOCAL_MACHINE, @"SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Path", path); DeleteKey("CsScript"); DeleteKey(@".cs\ShellNew"); DeleteKey(@".ccs"); //restore the original file type CopyKeyValue(".cs", "pre_css_default", ""); CopyKeyValue(".cs", "pre_css_contenttype", "Content Type"); DeleteKeyValue(".cs", "pre_css_default"); DeleteKeyValue(".cs", "pre_css_contenttype"); using (RegistryKey csKey = GetKey(".cs", true)) if (csKey.GetValue("OldDefault") != null) { csKey.SetValue("", csKey.GetValue("OldDefault").ToString()); } deleteFile(Environment.ExpandEnvironmentVariables(@"%CSSCRIPT_DIR%\cscs.exe.config")); deleteFile(Environment.ExpandEnvironmentVariables(@"%CSSCRIPT_DIR%\csws.exe.config")); deleteFile(Environment.ExpandEnvironmentVariables(@"%CSSCRIPT_DIR%\css_config.xml")); SplashScreen.HideSplash(); MessageBox.Show("CS-Script has been deactivated.\nPlease note that some files may still be locked by external applications (e.g. Windows Explorer)", "CS-Script Configuration"); } catch (Exception e) { MessageBox.Show("Cannot perform uninstall operation.\n" + e.ToString(), "CS-Script Configuration"); } }