This page is about different ways to integrate Emacs into MS Windows:

Run Emacs from a `cmd' Window

Put the Emacs ‘bin’ folder in the Windows PATH environment variable (right-click Computer, Properties, Advanced, Environment Variables). This also simplifies other methods mentioned on this page (no explicit paths needed then).

Use a Shortcut

Use this code for a desktop/task-bar shortcut:

emacsclientw.exe -na "" -c

This shortcut starts Emacs from scratch if it’s not running, and opens a new frame if it is.

The -c is key: without it, you have to pass a file to open or else emacsclient will exit with an error. (Right-click on desktop, New Shortcut, etc., then drag the shortcut into the Quick-Launch bar if you want.)

  -n means no wait - don't wait for the server to return
  -a EDITOR specifies to the emacsclientw.exe which editor to run if emacs.exe is not running. An empty string starts a new server if needed
  -c tells emacs to create a new frame instead of trying to use the existing frame

Milouse, 2013/03/08: on Windows XP and Gnu/Emacs 24.2, I have to use the following shortcut to have things working as expected with a non integrated Emacs (just unziped version somewhere in my computer) [If you don’t want to or can’t add the emacs path to %PATH% as described above – garyo] :

C:\Path\To\emacsclientw.exe --alternate-editor="C:\Path\To\runemacs.exe" -c

And, more important thing: you have to put the (server-start) declaration in your init.el file, otherwise the shortcut will keep creating new and disconnected instance of emacs.

Create File Associations

To open text files with the emacs daemon, run cmd.exe as administrator use the commands and ‘ftype’ and ‘assoc’:

    ftype txtfile=emacsclientw -na runemacs "%1"
    ftype EmacsLisp=emacsclientw -na runemacs "%1"
    ftype CodeFile=emacsclientw -na runemacs "%1"
    assoc .txt=txtfile
    assoc .text=txtfile
    assoc .log=txtfile
    assoc .org=txtfile
    assoc .el=EmacsLisp
    assoc .c=CodeFile
    assoc .h=CodeFile

Context Menu "Edit with Emacs," Windows 7 or earlier

Save the following text to a file explorer-edit-with-emacs.reg, fix the paths, then double-click it.

Windows Registry Editor Version 5.00
;; Search and replace C:\\path\\to\\emacs with the right path on your system

;; If emacs isn't running and server isn't running, will open directly in emacs
;; If emacs is running with server, opens using emacsclientw (C-# when done)

;; To automatically start server, add to ~/.emacs, remove semicolons:
;; (cond ((eq system-type 'windows-nt)
;;        (require 'server)
;;        (unless (server-running-p)
;;          (server-start))))

@="&Edit with Emacs"

@="C:\\path\\to\\emacs\\bin\\emacsclientw.exe -a C:\\path\\to\\emacs\\bin\\runemacs.exe \"%1\""

Right-click a file in Windows Explorer to see “Edit with Emacs.”

Tested with Windows 7 and Emacs 24.5.1.

Context Menu "Edit with Emacs," Windows 10

Save the following text to a file with emacs_explorer_integration.reg, replace the paths to Emacs binaries to match the location on your system. Double click the file and confirm the security warning to add this to the registry.

Windows Registry Editor Version 5.00
;; Be sure to set the correct path to Emacs on your system

;; Open file in existing frame
@="&Emacs: Edit in existing window"
@="c:\\path_to\\emacs\\bin\\emacsclientw.exe -n --alternate-editor=\"c:\\path_to\\emacs\\bin\\emacsclient.exe\" -n \"%1\""

;; Open file in new frame
@="&Emacs: Edit in new window"
@="c:\\path_to\\emacs\\bin\\emacsclientw.exe -n --alternate-editor=\"c:\\path_to\\emacs\\bin\\emacsclient.exe\" -c -n \"%1\""

;; Dired for desktop background
@="&Emacs: Open in dired"
@="c:\\path_to\\emacs\\bin\\emacsclientw.exe  -n --alternate-editor=\"c:\\path_to\\emacs\\bin\\emacsclient.exe\" -n \"%v\""

;; Dired for directory
@="&Emacs: Open in dired"
@="c:\\path_to\\emacs\\bin\\emacsclientw.exe  -n --alternate-editor=\"c:\\path_to\\emacs\\bin\\emacsclient.exe\" -n \"%V\""

;; Dired for directory background
@="&Emacs: Open in dired"
@="c:\\path_to\\emacs\\bin\\emacsclientw.exe  -n --alternate-editor=\"c:\\path_to\\emacs\\bin\\emacsclient.exe\" -n \"%V\""

;; Dired for drive background
@="&Emacs: Open in dired"
;; as drives haven't space inside their name don't use quoting
@="c:\\path_to\\emacs\\bin\\emacsclientw.exe  -n --alternate-editor=\"c:\\path_to\\emacs\\bin\\emacsclient.exe\" -n %L"

;; Dired for drive
@="&Emacs: Open in dired"
;; as drives haven't space inside their name don't use quoting
@="c:\\path_to\\emacs\\bin\\emacsclientw.exe  -n --alternate-editor=\"c:\\path_to\\emacs\\bin\\emacsclient.exe\" -n %L"

You should immediately see the options if you right click any file in explorer.

Set `emacsclient' as Your Editor

This almost works:

  git config --global core.editor "emacsclient -a emacs '%*'"

Do not use emacsclientw here; it doesn’t wait.

Replace `notepad.exe` calls

A quick and dirty way to replace all notepad.exe calls from any application (and your file manager) would be to use the Registry:

1. Start regedit.exe

2. Go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion?\Image File Execution Options

3. Add a new key named notepad.exe

4. Add (in there) a new string named Debugger and use this value: emacsclientw.exe -na runemacs.exe -F (requires emacsclientw to be in your PATH)

Note that this will pretty much break the usual -F behavior but it is needed as emacsclientw has no -z parameter (yet).

== Workaround to get`term`/`ansi-term` working with `cmd.exe` or Cygwin bash

Check out [1]. This is your best bet to get `term`/`ansi-term` working with a proper shell on Windows with Win32 Emacs.

You will need Cygwin installed to build it.

Windows 10/Emacs 25-*

Run Emacs server at windows startup & create shortcut to Emacs client

In your Emacs/bin directory (where your Emacs binaries are) create a shortcut to runemacs.exe. You may right-click on file runemacs.exe and choose send-to desktop (create shortcut).

Right click on newly created shortcut and choose Properties. In Target put following: "X:\path\to\emacs\bin\runemacs.exe" --daemon , X:\path\to\emacs is your drive letter and path where emacs resides on your harddrive. Close the properties dialog.

Press Win+r to open Run dialog and type shell:startup.

Copy your newly created link to Emacs server into opened directory. Emacs will start up automatically next time you start the system. Double click on the shortcut to start Emacs server now if it is not already running.

In your Emacs/bin directory, create a new shortcut file to emacsclientw.exe. Open Properties for newly created shortcut and in Target type: X:\path\to\emacs\bin\emacsclientw.exe -na "X:\path\to\emacs\bin\runemacs.exe" -c -n In Open in field, type %Documents% or whatever your choice for default directory is. Close the Properties dialog and rename your shortcut to just: emacs Drag your newly created shortcut to your startbar, or desktop or wherever you wish to have it.

OBS: No need to edit your .emacs file and add server line to it.

Send-To Context Menu

Press Win+r and in Run dialog type shell:sendto. Copy your newly created shortcut to emacs client to folder that just opened. This will create an entry in send to context menu so you can right click on any document and choose to open it in Emacs.

Debug Version

Sometimes it is useful to be able to start up default autonomous copy of Emacs (not client/server), for example if you play with your config file and something gets messed up.

Create a new shortcut to “emacs.exe”. Right click newly created shortcut and choose properties. In target field type: "X:\path\to\emacs\bin\emacs.exe" --debug-init Close properties dialog.