Function: tramp-smb-call-winexe

tramp-smb-call-winexe is a byte-compiled function defined in tramp-smb.el.gz.

Signature

(tramp-smb-call-winexe VEC)

Documentation

Apply a remote command, if possible, using tramp-smb-winexe-program.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-smb.el.gz
(defun tramp-smb-call-winexe (vec)
  "Apply a remote command, if possible, using `tramp-smb-winexe-program'."
  ;; Check for program.
  (unless (executable-find tramp-smb-winexe-program)
    (tramp-error
     vec 'file-error "Cannot find program: %s" tramp-smb-winexe-program))

  ;; winexe does not supports ports.
  (when (tramp-file-name-port vec)
    (tramp-error vec 'file-error "Port not supported for remote processes"))

  ;; Check share.
  (unless (tramp-smb-get-share vec)
    (tramp-error vec 'file-error "Default directory must contain a share."))

  ;; In case of "NT_STATUS_RPC_SS_CONTEXT_MISMATCH", the remote server
  ;; is a Samba server.  winexe cannot install the respective service there.
  (tramp-smb-maybe-open-connection
   vec
   (format
    "%s %s"
    tramp-smb-winexe-shell-command tramp-smb-winexe-shell-command-switch))

  (add-hook 'kill-buffer-hook #'tramp-smb-kill-winexe-function nil t)

  ;; Suppress "^M".  Shouldn't we specify utf8?
  (set-process-coding-system (tramp-get-connection-process vec) 'raw-text-dos)
  ;; Enable UTF-8 encoding.  Suppress "^M".
  ;; (set-process-coding-system (tramp-get-connection-process vec) 'utf-8-dos)
  ;; (tramp-smb-send-command vec "$PSDefaultParameterValues['*:Encoding'] = 'utf8'")
  ;; This avoids mixing prompt and long error messages.
  (tramp-smb-send-command vec "$rawui = (Get-Host).UI.RawUI")
  (tramp-smb-send-command vec "$rawui.WindowSize = $rawui.MaxWindowSize")
  (tramp-smb-send-command vec "$rawui.BufferSize.Width = 1024")
  ;; Goto `default-directory'.
  (tramp-smb-send-command
   vec (format
	"cd //%s%s"
	(tramp-file-name-host vec)
	(tramp-smb-shell-quote-localname vec 'share))))