Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open link fails with "Access is denied" ShellExecute error #4

Open
fleimgruber opened this issue Dec 16, 2014 · 12 comments
Open

Open link fails with "Access is denied" ShellExecute error #4

fleimgruber opened this issue Dec 16, 2014 · 12 comments

Comments

@fleimgruber
Copy link

Emacs 24.4.1
Outlook 2010

org-outlook-open fails in the else call at

(w32-shell-execute "open" (concat "outlook:" id))

with the error

error: "ShellExecute failed: Access is denied."

Do you know what could be causing this? Does Emacs need special privileges? Is this a missing setting in outlook?

@mattfidler
Copy link
Owner

Sorry, for the late reply. You need org-protocol to be setup, including the protocol itself so that entering org-protocol from internet explorere will open emacs.

I haven't checked Emacs 24.4 to see if there are any differences. I'm working on emacs 24.3

@fleimgruber
Copy link
Author

org-protocol:// works fine from an iexplore, i.e. I get an Emacs buffer in the running instance.

Still the same error. Will try with Emacs 24.3 - any other hints on debugging in the meantime?

@mattfidler
Copy link
Owner

I can't reproduce it, so I'm stumped :(

@mattfidler
Copy link
Owner

Perhaps you are having write access to a temp file?

@fleimgruber
Copy link
Author

How would you test with the temp file? BTW, have you tried with emacs 24.4 already?

@mattfidler
Copy link
Owner

I haven't tested the emacs 24.4, but if explorer opens the emacs link, then
its because outlook settings are conservative and think you are opening a
virus.

I use a key-binding in outlook, so I can't remember if this happened for me
in an upgrade. You could script it in autohotkey. This is what I did for
ergoemacs-mode autohotkey script:

execute-extended-command:
  ;; Send to org-outlook if using outlook
  If !WinActive("ahk_class Emacs"){
       If WinActive("ahk_class rctrl_renwnd32"){
          If !FileExist(OutlookSave){
             FileSelectFolder, OutlookSave, ,3, Select Folder to Save
Outlook Emails
             IniWrite, %OutlookSave%, ergoemacs-settings.ini, Outlook, Save
          }
          If !FileExist(EmacsClient){
             FileSelectFile, EmacsClient, 1, , Emacs Client, Emacs Client
(emacs*.exe)
             IniWrite, %EmacsClient%, ergoemacs-settings.ini, Emacs,
EmacsClient
          }
          If (OutlookTemplate == "ERROR") {
                InputBox OutlookTemplate, Org-mode capture template for
emails (can't be blank)
                IniWrite, %OutlookTemplate%, ergoemacs-settings.ini,
Outlook, Template

          }
          Clipboard=
          SendKey("{Ctrl down}{c}{Ctrl up}")
          ClipWait
          EmailBody=%clipboard%
          EmailBody:=uri_encode(EmailBody)
          SendKey("{F12}",0)
          Clipboard=
          While !WinActive("Save As"){
                Sleep 100
          }
          SendKey("{Ctrl down}{c}{Ctrl up}")
          ClipWait
          Counter = 1
          Title=%clipboard%
          Title := uri_encode(Title)
          fileName = %OutlookSave%\%clipboard%-%Counter%.msg
          while FileExist(fileName)
          {
             Counter := Counter + 1
             fileName = %OutlookSave%\%clipboard%-%Counter%.msg
          }
          Clipboard =
          Clipboard := fileName
          ClipWait
          While !WinActive("Save As"){
                Sleep 100
          }
          SendKey("{Backspace}")
          SendInput, %Clipboard%
          SendKey("{Enter}")
          While WinActive("Save As"){
                Sleep 100
          }
          SendKey("{Del}")
          fileName := uri_encode(fileName)
          fileName = "%EmacsClient%"
org-protocol:/capture:/%OutlookTemplate%/%fileName%/%Title%/%EmailBody%
          Run, %fileName%
          }
  }
  return

@fleimgruber
Copy link
Author

I don't understand how the autohotkey script is related to the issue.

Is the ahk script then supposed to be run in the w32-shell-execute?

@mattfidler
Copy link
Owner

The w32-shell-execute is often blocked by corporations or security settings in outlook. Autohotkey is a windows scripting solution that allows you to send keys and actions to windows and then run them by binding them to a keyboard shortcut (http://www.autohotkey.com/). In this case, the autohotkey script saves the email to somewhere in your hard-drive, and then sends the link to emacs directly without having to use w32-shell-execute. Hence it is a work-around.

@mattfidler
Copy link
Owner

Without testing, I think this autohotkey script would work. It binds the action key to M-x

!x::
         OutlookSave="c:\org-outlook-messages\"
         EmacsClient="c:\emacs\bin\emacsclient.exe"
         OutlookTemplate=""
         Clipboard=
          SendKey("{Ctrl down}{c}{Ctrl up}")
          ClipWait
          EmailBody=%clipboard%
          EmailBody:=uri_encode(EmailBody)
          SendKey("{F12}",0)
          Clipboard=
          While !WinActive("Save As"){
                Sleep 100
          }
          SendKey("{Ctrl down}{c}{Ctrl up}")
          ClipWait
          Counter = 1
          Title=%clipboard%
          Title := uri_encode(Title)
          fileName = %OutlookSave%\%clipboard%-%Counter%.msg
          while FileExist(fileName)
          {
             Counter := Counter + 1
             fileName = %OutlookSave%\%clipboard%-%Counter%.msg
          }
          Clipboard =
          Clipboard := fileName
          ClipWait
          While !WinActive("Save As"){
                Sleep 100
          }
          SendKey("{Backspace}")
          SendInput, %Clipboard%
          SendKey("{Enter}")
          While WinActive("Save As"){
                Sleep 100
          }
          SendKey("{Del}")
          fileName := uri_encode(fileName)
          fileName = "%EmacsClient%"
org-protocol:/capture:/%OutlookTemplate%/%fileName%/%Title%/%EmailBody%
          Run, %fileName%
 return

@fleimgruber
Copy link
Author

With the latest ahk (v 1.1.21.03) I get the error

Error: Call to nonexistent function

Specifically: SendKey("{Ctrl down}{c}{Ctrl up}")

Binding M-x in this way would intercept it globally, wouldn't it?

Also, do you know what the corresponding outlook security setting would be?

@fleimgruber
Copy link
Author

I resorted to directly using the IMAP server via gnus and link to mail through the gnus:nnimap link types.

@mattfidler
Copy link
Owner

Sorry. Perhaps if I have time, I will write a script to setup the
autohotkey support.

On Tue, Apr 28, 2015, 8:55 AM fleimgruber notifications@github.com wrote:

I resorted to directly using the IMAP server via gnus and link to mail
through the gnus:nnimap link types.


Reply to this email directly or view it on GitHub
#4 (comment)
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants