To: vim-dev@vim.org Subject: patch 5.4.x7 Fcc: outbox From: Bram Moolenaar ------------ Since I didn't get complaints that the test version for the DOS uninstall program I sent out a week ago caused problems, here is the patch for it. Patch 5.4.x7 Problem: Win32 GUI: Removing "Edit with Vim" from registry is difficult. Solution: Add uninstal program to remove the registry keys. It is installed in the "Add/Remove programs" list for ease of use. Also: don't set $VIM when the executable is with the runtime files. Also: Add a text file with a step-by-step description of how to uninstall Vim for DOS and Windows. Files: src/uninstal.c, src/dosinst.c, src/Makefile.w32, uninstal.txt *** ../vim-5.4.41/src/uninstal.c Thu Jan 1 01:00:00 1970 --- ./src/uninstal.c Sat Aug 14 16:02:19 1999 *************** *** 0 **** --- 1,66 ---- + /* vi:set ts=8 sts=4 sw=4: + * + * VIM - Vi IMproved by Bram Moolenaar + * + * Do ":help uganda" in Vim to read copying and usage conditions. + * Do ":help credits" in Vim to see a list of people who contributed. + */ + + /* + * uninstal.c: Minimalistic uninstall program for Vim on MS-Windows + * Only removes the "Edit with Vim" popup menu entry. + * + * Compile with Makefile.w32. + */ + + #include + #include + #include + #ifdef WIN32 + # include + #endif + #include "version.h" + + /* + * Return TRUE if the user types a 'y' or 'Y', FALSE otherwise. + */ + int + confirm(void) + { + char answer[10]; + + return (scanf(" %c", answer) == 1 && toupper(answer[0]) == 'Y'); + } + + int + main(int argc, char *argv[]) + { + int fail = 0; + + printf("This program will remove the \"Edit with Vim\" entry from the popup menu\n"); + printf("Continue (y/n)? "); + if (confirm()) + { + if (RegDeleteKey(HKEY_CLASSES_ROOT, "*\\shell\\Vim\\command") + != ERROR_SUCCESS) + ++fail; + if (RegDeleteKey(HKEY_CLASSES_ROOT, "*\\shell\\Vim") != ERROR_SUCCESS) + ++fail; + if (RegDeleteKey(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Vim " VIM_VERSION_SHORT) != ERROR_SUCCESS) + ++fail; + if (fail == 3) + printf("No Vim registry entries could be removed\n"); + else if (fail) + printf("Some Vim registry entries could not be removed\n"); + else + printf("The Vim registry entries have been removed\n"); + } + else + printf("Nothing changed\n"); + + while (getchar() != '\n') /* eat the newline for the confirm() above */ + ; + printf("\nHit return to exit..."); + (void)getchar(); + } + *** ../vim-5.4.41/src/dosinst.c Sun Jul 25 13:44:55 1999 --- ./src/dosinst.c Sat Aug 21 15:30:07 1999 *************** *** 9,15 **** /* * install.c: Minimalistic install program for Vim on MS-DOS/Windows * ! * Compile with Makefile.bcc or Makefile.djg. */ #include --- 9,15 ---- /* * install.c: Minimalistic install program for Vim on MS-DOS/Windows * ! * Compile with Makefile.w32, Makefile.bcc or Makefile.djg. */ #include *************** *** 443,448 **** --- 443,472 ---- return exedir; /* return dir name where exe is */ } + /* + * Copy a directory name from "dir" to "buf", doubling backslashes. + */ + static void + double_bs(char *dir, char *buf) + { + char *d = buf; + char *s; + + for (s = dir; *s; ++s) + { + if (*s == '\\') + *d++ = '\\'; + *d++ = *s; + } + /* when dir is not empty, it must end in a double backslash */ + if (d > buf && d[-1] != '\\') + { + *d++ = '\\'; + *d++ = '\\'; + } + *d = 0; + } + #define TABLE_SIZE(s) sizeof(s) / sizeof(char *) int *************** *** 481,486 **** --- 505,511 ---- int i; char *p; int vimdirend; + int need_vimvar = 1; /* need to set $VIM */ #ifdef DJGPP /* *************** *** 657,679 **** } /* - * Set $VIM, if it hasn't been set yet. - */ - if (getenv("VIM") == NULL) - { - printf("\nI can append a command to c:\\autoexec.bat to set $VIM.\n"); - printf("(this will not work if c:\\autoexec.bat contains sections)\n"); - printf("Do you want me to append to your c:\\autoexec.bat? (Y/N) "); - if (!confirm()) - printf("Skipping appending to c:\\autoexec.bat\n"); - else - { - vimrc[vimdirend - 1] = NUL; - append_autoexec("set VIM=%s\n", vimrc); - } - } - - /* * Set PATH or move executables, unless it's already in the $PATH. */ mch_chdir("C:\\"); /* avoid looking in the "vimrdir" directory */ --- 682,687 ---- *************** *** 693,698 **** --- 701,707 ---- switch (exe) { case 1: append_autoexec("set PATH=%%PATH%%;%s\n", vimdir); + need_vimvar = 0; break; case 2: exedir = move_to_path(vimdir); *************** *** 705,710 **** --- 714,736 ---- } /* + * Set $VIM, if it hasn't been set yet. + */ + if (need_vimvar && getenv("VIM") == NULL) + { + printf("\nI can append a command to c:\\autoexec.bat to set $VIM.\n"); + printf("(this will not work if c:\\autoexec.bat contains sections)\n"); + printf("Do you want me to append to your c:\\autoexec.bat? (Y/N) "); + if (!confirm()) + printf("Skipping appending to c:\\autoexec.bat\n"); + else + { + vimrc[vimdirend - 1] = NUL; + append_autoexec("set VIM=%s\n", vimrc); + } + } + + /* * Add some entries to the registry to add "Edit with Vim" to the context * menu. */ *************** *** 726,760 **** else { char buf[BUFSIZE]; - char *s, *d; ! /* double the backslashes in the directory */ ! d = buf; ! for (s = exedir; *s; ++s) ! { ! if (*s == '\\') ! *d++ = '\\'; ! *d++ = *s; ! } ! /* when dir is not empty, it must end in a double backslash */ ! if (d > buf && d[-1] != '\\') ! { ! *d++ = '\\'; ! *d++ = '\\'; ! } ! *d = 0; fprintf(fd, "REGEDIT4\n\n"); fprintf(fd, "[HKEY_CLASSES_ROOT\\*\\shell\\Vim]\n"); fprintf(fd, "@=\"Edit with &Vim\"\n\n"); fprintf(fd, "[HKEY_CLASSES_ROOT\\*\\shell\\Vim\\command]\n"); ! fprintf(fd, "@=\"%sgvim.exe \\\"%%L\\\"\"\n", buf); fclose(fd); system("regedit vim.reg"); /* Can't delete the file, because regedit detaches itself, ! * thus we don't know when it is finished */ ! /* unlink("vim.reg"); */ printf("The registry editor has been started to install Vim in the popup menu.\n"); ! printf("If you want to remove it, see \":help win32-popup-menu\" in Vim.\n"); } } } --- 752,781 ---- else { char buf[BUFSIZE]; ! /* The registry entries for the "Edit with Vim" menu */ fprintf(fd, "REGEDIT4\n\n"); fprintf(fd, "[HKEY_CLASSES_ROOT\\*\\shell\\Vim]\n"); fprintf(fd, "@=\"Edit with &Vim\"\n\n"); fprintf(fd, "[HKEY_CLASSES_ROOT\\*\\shell\\Vim\\command]\n"); ! double_bs(exedir, buf); /* double the backslashes */ ! fprintf(fd, "@=\"%sgvim.exe \\\"%%L\\\"\"\n\n", buf); ! ! /* The registry entries for uninstalling the menu */ ! fprintf(fd, "[HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\vim %s]\n", VIM_VERSION_SHORT); ! fprintf(fd, "\"DisplayName\"=\"Vim %s: Edit with Vim popup menu entry\"\n", VIM_VERSION_SHORT); ! double_bs(vimdir, buf); /* double the backslashes */ ! fprintf(fd, "\"UninstallString\"=\"%suninstal.exe\"\n", buf); ! fclose(fd); system("regedit vim.reg"); /* Can't delete the file, because regedit detaches itself, ! * thus we don't know when it is finished. */ ! printf("The registry editor has been started to install Vim in the popup menu.\n"); ! printf("Hit the \"Yes\" button in the dialog to confirm this.\n\n"); ! printf("Use uninstal.exe if you want to remove it again.\n"); ! printf("Also see \":help win32-popup-menu\" in Vim.\n"); } } } *** ../vim-5.4.41/src/Makefile.w32 Sun Jun 6 18:51:26 1999 --- ./src/Makefile.w32 Sat Aug 21 15:35:08 1999 *************** *** 280,286 **** --- 280,290 ---- install.exe: dosinst.c $(CC) -DWIN32 dosinst.c kernel32.lib shell32.lib + - del install.exe ren dosinst.exe install.exe + + uninstal.exe: uninstal.c + $(CC) -DWIN32 uninstal.c advapi32.lib vimrun.exe: vimrun.c $(CC) vimrun.c *** ../vim-5.4.41/uninstal.txt Thu Jan 1 01:00:00 1970 --- ./uninstal.txt Sat Aug 21 15:14:08 1999 *************** *** 0 **** --- 1,48 ---- + Uninstalling Vim on Dos and MS-Windows. + + To remove a version of Vim you must do some handwork. But it isn't difficult, + just follow these steps: + + 1. Remove the "Edit with Vim" popup menu entry, if it exists. This will only + be on MS-Windows 95/98/NT. This is done by running the uninstal.exe + program. It removes the registry entries for the "Edit with Vim" popup + menu entry. You only need to run uninstal.exe when you have installed the + menu entry. You can also run uninstal.exe from the Control panel with the + Add/Remove programs application. + + 2. Only if you have used the OLE version of gvim: Remove the registration of + this program by running "gvim -unregister" in a console window. + + 3. Delete the executables. If you copied the executables to another location, + you will have to delete them from where you copied them to. If you don't + remember where they are, look in the directories from the $PATH environment + variable. + + 4. If you completely want to delete vim, and are not going to install another + version, you can delete the vimrc files that you created. These are + normally located in a directory like "C:\vim". If the $VIM environment + variable is set, it will tell the name of the directory. Normally you can + delete everything in this directory. Warning: You might have put some + files there that you would like to save. If you did remove it all, you can + skip the next step. + + 5. Delete the distributed files. If you followed the directions, these will + be located in a directory like "C:\vim\vim54". If the $VIM environment + variable is set, the directory will be $VIM\vim54. Delete the "vim54" + directory and all that is in it. Warning: If you changed any of the + distributed files, or added some of your own files, you might want to save + these first. But normally you would not have changed or added files here. + + 6. Remove setting the $VIM and $VIMRUNTIME environment variable and adjust + $PATH. $VIM only needs to be removed if you are not going to install + another version of Vim. $VIMRUNTIME is mostly not set. Check if $PATH + contains the path of the vim directory. Note that $PATH may be set in + several places, you will have to find the right one, and only delete the + Vim path from it. You can most likely find the lines that set $PATH, $VIM + and/or $VIMRUNTIME in C:\autoexec.bat. Under Windows NT you might need to + use the "System Properties" editor to change the environment variables, if + they are not in the C:\autoexec.bat file. You can start it by selecting + Start/Settings/Control Panel and then "System". + + Vim does not use .dll or .ini files. The above should remove all Vim files, + except the ones that you moved elsewhere yourself. -- hundred-and-one symptoms of being an internet addict: 176. You lie, even to user-friends, about how long you were online yesterday. --/-/---- Bram Moolenaar ---- Bram@moolenaar.net ---- Bram@vim.org ---\-\-- \ \ www.vim.org/iccf www.moolenaar.net www.vim.org / /